Customized Bash Prompt

Posted in Systems on July 12th, 2010 by Angelo – Be the first to comment

The following sites inspired me to explore creating a customized prompt (for bash):

So here is mine:

PS1="\$(if [[ \$? != "0" ]]; then echo \[\e[31m\]; fi)\n\$(date)\n\\[\e[1m\\]\[\$(dirs)\]\n\\[\e[m\\]"
PS2=""

Features:

  • Color change on error return code
  • The current date
  • The current directory stack (I use pushd and popd)
  • Commands start on their own line

And that’s it!  I really don’t need the prompt to tell me what my username is or the hostname of the machine (duh!).

Rsync Speed-up

Posted in Systems on May 25th, 2010 by Angelo – Be the first to comment

Online docs say that rsync sends only the differences and “information about structure” but my experience seems to indicate otherwise. So I ran a little test too on a file where I just changed the timestamp without changing the file contents:

$ cp -a testfile-100M destfile

$ rsync -av testfile-100M destfile
sending incremental file list

sent 56 bytes received 12 bytes 8.00 bytes/sec
total size is 104857600 speedup is 1542023.53

$ touch testfile-100M

$ rsync -av testfile-100M destfile sending incremental file list
testfile-100M

sent 104870495 bytes received 31 bytes 113804.15 bytes/sec
total size is 104857600 speedup is 1.00

I didn’t time it, but the initial cp easily took 1/3rd the time the final rsync did–I would estimate more like 1/4th or 1/5th the time. I’ve always read “speedup is 1.00″ as “this is equivalent to having copied the whole file.” Meaning I gained no speedup over just transmitting the file regularly, as calculated by the algorithm.

I think what might be going on is that when rsync sees the timestamp has changed it transfers the file. But in doing so, it does a diff on the contents which is slower than just copying a file.

DOS Disk/Flash BIOS

Posted in Systems on April 12th, 2010 by Angelo – Be the first to comment

These are some notes on making a DOS disk using FreeDOS for those of us with Linux needing to do things like flash our BIOS.


wget -c http://fdos.org/bootdisks/autogen/FDOEM.144.gz
gunzip FDOEM.144.gz
mount -t vfat -o loop FDOEM.144 /mnt/floppy

Put the driver files on the floppy (stay within the space limit)

umount /mnt/floppy
mkisofs -o bootcd.iso -b FDOEM.144 FDOEM.144

Dragonskin Child Themes

Posted in Development on January 20th, 2010 by Angelo – 8 Comments

The Dragonskin Theme now also had child themes to give your site the skin of a different colored dragon. The child themes should be included in the download for the theme, and are simply used to modify the color scheme. You select them just as any other theme.

Note: The WordPress repository did not support child themes when I uploaded version 1.5.  Therefore, they will not be included in that package.  Please download them from this page below (added).  My intention for the next version is to include all of them in one package with an switching tool on the admin menu to select the one to use.

Dragonskin Gold

Dragonskin Gold Screenshot

Dragonskin Gold

Download Dragonskin Gold 1.5

Dragonskin Green

Dragonskin Green Screenshot

Dragonskin Green

Download Dragonskin Green 1.5

Automatically show WP-PostRatings on your posts

Posted in Development on January 20th, 2010 by Angelo – 1 Comment

For the longest time, my Dragonskin Theme has had WP-PostRatings integration. Recently I removed the integration because it is easy to modify the rating plugin to accomplish the same goal. (I hope that in the future WP-PostRatings will provide a simple way to do this through the admin interface–it really isn’t that hard.)

All you need to do is open wp-postratings/wp-postratings.php and find a line that looks like this:

//add_action('the_content', 'add_ratings_to_content');

Simply uncommenting that line will put the post ratings at the bottom of every post and page. In Dragonskin, I only included it on posts and at the top. To achieve the same, make some modifications to the next block of code, so that it looks like this:


function add_ratings_to_content($content) {
if (!is_feed()|!is_page()) {
$content = the_ratings('div', 0, false).$content;
}
return $content;
}

Using Akismet Class with Spamwords for phpBB2

Posted in Development on January 19th, 2010 by Angelo – Be the first to comment

I followed the instructions here for installing an akismet-based spam filter on phpBB2, but I found that it didn’t play nicely enough with the current Akismet API.  So instead, I downloaded an Akismet class and used that instead.  Basically, you should use Akismet.class.php instead of functions_akismet.php in your spamwords.php file.

  1. Install the spamwords mod
  2. Download Akismet.class.php and put this under your phpBB2 includes/ directory
  3. Modify the spamwords.php file so that it looks like this (include your Akismet API at the top):

WPMU Recent Posts Widget

Posted in Development on April 8th, 2009 by Angelo – 10 Comments

First of all, let me preface this posting by saying there are a lot of versions of a “sitewide” plugin to show recent posts.  There are however, no widgetized versions that I could find, so I made a simple one.

Download WPMU Recent Posts Widget

Latest version 1.1

Dragonskin WordPress Theme

Posted in Development on October 17th, 2008 by Angelo – 32 Comments

Wrap your blog in the skin of a dragon! This is a dark theme that has a nice look for RPG and gaming sites. I originally developed this theme to go along with my D&D fan site. It features CSS-drive drop-down menus, support for multiple authors, and fluid width for flexible resolutions. (See below for full list of features and details.)

If you like this theme please rate it at WordPress!

dragonskin screenshot

Example Site Using Dragonskin

Features

  • Widget enabled
  • Gravatar enabled
  • Drop-down menu
  • Supports an optional header image to replace the text tile (just include an image as images/header.gif)

Integrated Support for Plugins

Image Credits

Download

Version 1.3 – January 10, 2010

Version 1.2 – September 22nd, 2009

  • Separated the navigation bar to a separate file for easier modification (navbar.php)
  • Reduced the post area/black scroll width to see a little more of the background
  • Reduced transfer size (dragonskin-4bit.png)
  • Expanded author profile page to include all posts listing
  • Fixed bug that occurs if you have the optional files set unreadable – won’t generate an error on files existing without permissions
  • Added support for plugins
    • Coauthors
    • Smart 404
  • Replaced deprecated: link_pages, wp_list_cats, get_archives
  • Changed to display subcategories inline in drop-down menu
  • Removed code for Similar Posts plugin – the plugin includes a way to insert itself through the admin interface
  • Removed static-sidebar.php support
  • Removed clickheat support – http://wordpress.org/extend/plugins/easy-clickheat-intergration-plugin/
  • Removed post-banner.php support – suggest to use http://wordpress.org/extend/plugins/smart-ads/

Version 1.1 – December 9th, 2008

  • Fixed some accidental plugs for Heroes Only.
  • Fixed sidebar bug on archive pages pushing sidebar below the content
  • Licensed under GPL

Version 1.0 – October 17th, 2008

If you like this theme please rate it at WordPress!

CD/DVD Filesystem Snapshot

Posted in Systems on August 21st, 2008 by Angelo – Be the first to comment

This will work with other filesystems, not just ext2, so you may want to choose a filesystem that is similar to what you currently run (if you care). The idea is that instead of creating an ISO image that is very flexible (can be read by Windows), you create a filesystem image and burn it to disc. The advantage of this is that you can preserve filesystem properties such as permissions, ownership, etc. The disadvantage is that the straightforward approach (everything on one disk) only gives you about 4.5 G of space to work with (depending on the media size).

(1) Create a 2 GB image:
sudo dd if=/dev/zero of=snapshot.img bs=1024k count=2000 &
You can create a larger image size if you need it, and your burnable media can handle it.

(2) Format it using ext2
sudo mke2fs -m 0 -q -F -b 2048 snapshot.img 1>&2
Honestly, I can’t remember why I was redirecting output to stderr. Maybe I had a good reason for that. But suffice it to say, you simply want to use the file you created to make a file system. For example, instead of the above, you can use something like `mkfs -t xfs snapshot.img`

(3) Mount the image
sudo mount -t ext2 -o loop snapshot.img /mnt/snapshot
For the mount, you want to make sure to use whatever filesystem type you created the image with.

(4) Copy the data, preserving information
sudo rsync -avH --numeric-ids --progress --stats --delete --exclude /proc/ \
--exclude /sys/ --exclude /tmp/ --exclude /var/run/ --exclude /var/tmp/ \
--exclude /mnt/snapshot/ / /mnt/snapshot/

This is an example of copying the entire system (if it’s small enough to fit). In this example, you want to make sure you exclude the mount point for the snapshot, because otherwise you’ll have a recursive rsync that will go on forever. It’s definitely good to make sure you exclude /proc/ and /sys/ too. You could exclude /dev/ since today’s Linux just regenerates it on boot anyway. (If you were porting to other hardware you may want to do this to be “safe” but usually it’s safer to just keep a copy of it.) –progress and –stats are extraneous options, and if you’re a neat freak, you can use –delete-excluded too to make sure those directories are cleared out in case you accidentally copied things over.

(5) Unmount and burn using cdrecord
sudo umount /mnt/snapshot
sudo cdrecord -v -eject dev=/dev/cdrom snapshot.img

You can alternatively use any burning software to apply the image directly to burnable media.

Now keep in mind, that when you want to mount this CD/DVD you will need to mount it by hand, as root, using the filesystem type you burned it with. It’s a good idea to write the fs type on the CD along with whatever else you’re going to call it so you know how to mount it later.


rsync --verbose --progress --stats --compress -a --delete -H --numeric-ids --exclude "#*#" --exclude "*~" --exclude "/proc/*" --exclude "/dev/*" --exclude "/var/cache/*" --exclude "/tmp/*" --exclude "/var/tmp/*" descartes:/ /mnt/backup/rsync/descartes/

CutlineNegative

Posted in Development on December 14th, 2007 by Angelo – Be the first to comment

The CutlineNegative theme for WordPress is based on the Cutline theme by Chris Pearson. It’s main feature is that it produces a gray-on-black Cutline instead of the typical black-on-white.

CutlineNegative Screenshot

Download CutlineNegative-1.1 ZIP file

It has a few other personal tweaks, but if all you really care about is the color scheme, then you can simply download the custom.css file instead. Simply replace custom.css in the Cutline theme with the file below.

Download CutlineNegative-1.1 CSS file