Preserving file encoding when editing svn dump files

0 comments
Some text editors may automatically alter the encoding of svn dump files if you ever have to manually edit them. Make sure that you always preserve the original encoding of the dump file, otherwise checksums will be off when you eventually try to import the file. Using nano, for example, launch with the -N option... nano -N myfile.dmp

A simple model base using jquery events

0 comments
/**
 * Base class for all models in the app
 * 
 * @author  Brendan McMahon brendan.mcmahon@publicisdigital.com
 * @version $Id$
 */
var PMQuizModelBase = function() {
  /**
   * An element used for binding and triggering jquery events
   */
  var _element = $('<div/>');

  /**
   * Attributes/properties of our model
   */
  var _attributes = {};

  /**
   * Create and return the instance
   */
  var that = {

    /**
     * Proxy for the jQuery trigger method
     *
     * @param {string} eventType
     * @param {array} extraParameters
     */
    trigger: function(eventType, extraParameters) {
      _element.trigger(eventType, extraParameters);
    },

    /**
     * Proxy for the jQuery bind method
     *
     * @param {string} eventType
     * @param {object} eventData
     * @param {function} handler
     */
    bind: function(eventType, eventData, handler) {
      _element.bind(eventType, eventData, handler);
    },

    /**
     * Get an attribute
     *
     * @param {string} attribute
     *  The name of the attribute to retrieve
     *
     * @return the value of the attribute
     */
    get: function(attribute) {
      return _attributes[attribute];
    },

    /**
     * Set an attribute
     *
     * @param {string} attribute
     *  The name of the attribute to set
     * @param {object} value
     *  The new value for the object
     * @param {boolean} forceChange
     *  If true, a "model:change" event will be triggered, even if the attribute
     *  value has not changed
     *
     * @return {PMQuizModelBase} The model instance. Useful for method chaining
     */
    set: function(attribute, value, forceChange) {
      var oldValue = _attributes[attribute];

      _attributes[attribute] = value;

      if (oldValue != value || forceChange) {
        this.trigger('model:change', [attribute, oldValue, value]);
      }

      return this;
    }
  }

  return that;
}

Subversive on eclipse helios

0 comments
Ignore the hype... Just install the older versions from these update sites

http://download.eclipse.org/technology/subversive/0.7/update-site/
http://community.polarion.com/projects/subversive/download/eclipse/2.0/update-site/

lftp or rsync recipes simple site deployments

0 comments
Choose your poison. Rsync over ssh looks like this. In rsync.sh
#!/bin/sh
rsync -ravz --delete -e ssh localdir user@server.com:/remote/path
In lftp.sh:
#!/bin/bash    
HOST="server.com"
USER="user"
PASS="pass"
LCD="../local/path"
RCD="/remote/path"
lftp -c "set ftp:list-options -a;
open sftp://$USER:$PASS@$HOST;
lcd $LCD;
cd $RCD;
mirror --reverse \
       --delete \
       --verbose \
       --parallel=8 \
       --exclude-glob .svn/"

Custom author name in netbeans templates

1 comments
Netbeans uses the user.name java system var as the value of the ${user} token in code templates. The value can easily be set when netbeans launches by adding the following to the command used to launch netbeans:
-J-Duser.name="Super Awesome Dude (superawesome[at]dude.com)"
So the full command would look something like this:
/path/to/netbeans-6.9.1/bin/netbeans -J-Duser.name="Super Awesome Dude (superawesome[at]dude.com)"

Backup with Amazon S3

0 comments
Awesome stuff http://blog.eberly.org/2008/10/27/how-i-automated-my-backups-to-amazon-s3-using-rsync/

Home network backup with rsync and ssh under Ubuntu

0 comments
Generate ssh key pair. We'll create a passphraseless pair for the backup, so we don't need to supply the passphrase when executing the script as root. Generate a keypair on the client. Save it to some unique name, like backup-key
$ ssh-keygen -t dsa -b 2048 -f /home/user/.ssh/backup-key
Generating public/private dsa key pair.
Enter passphrase (empty for no passphrase): [press enter here]
Enter same passphrase again: [press enter here]
Your identification has been saved in /home/user/.ssh/backup-key.
Your public key has been saved in /home/user/.ssh/backup-key.pub.
The key fingerprint is:
2e:28:d9:ec:85:21:e7:ff:73:df:2e:07:78:f0:d0:a0 user@host 

Copy the public key up to the server.
scp /home/user/.ssh/backup-key.pub serverusername@server:./backup-key.pub
Now ssh over to the server and add your public key...
username@server:~$ cd .ssh
serverusername@server:~$ touch authorized_keys2
serverusername@server:~$ chmod 600 authorized_keys2
serverusername@server:~$ cat ../backup-key.pub >> authorized_keys2
serverusername@server:~$ rm ../backup-key.pub
Create the following shell script on each client. Ideally stick this in Anacrons /etc/cron.daily folder to have it run once per day.
#!/bin/sh

# This script does backups of foo to the backup server bar
# in a 7 day rotating incremental backup.
# Based on script by Andrew Tridgell

# directory to backup
BDIR=/path/to/backup

# Remote directory on backup server
BACKUP_HOME=/backups

# Backup login account on remote server
BACKUP_LOGIN=user

# the name of the backup server
BSERVER=ubuntu-server
BACKUPDIR=`date +%A`

export PATH=$PATH:/bin:/usr/bin:/usr/local/bin

# Dump output to backup file
date > /var/log/backup.$BACKUPDIR.log

# the following line clears the last week's incremental directory
[ -d /tmp/emptydir ] || mkdir /tmp/emptydir
rsync -e "ssh -i /home/user/.ssh/backup-key" --delete -a /tmp/emptydir/ $BACKUP_LOGIN@$BSERVER:$BACKUP_HOME/$BACKUPDIR/
rmdir /tmp/emptydir

# now the actual transfer
rsync -r -e "ssh -i /home/user/.ssh/backup-key" --force --ignore-errors --delete --backup --backup-dir=$BACKUP_HOME/$BACKUPDIR -av $BDIR $BACKUP_LOGIN@$BSERVER:$BACKUP_HOME/current >> /var/log/backup.$BACKUPDIR.log