Git Push/Pull Alias Functions

I’ve been using Git for just over two years now. It’s one of the few systems left that doesn’t have a graphical user interface I prefer. In the past years, many choices have either been launched or announced but I’m still a command-line only person.

I grew tired of typing the full push/pull commands so I’ve finally spent some time searching for the best bash function on the net… which appears to be http://forrst.com/posts/My_gitstuff_bash_shortcuts_for_working_with_g-BwI

Edit your bash profile and place the “gpush” and “gpull” functions after anything that currently exists. I personally didn’t use the aliases shown in the pasted code sample, as I already use a different set.

vi ~/.bash_profile

When running gpush or gpull they will activate the associated commands on the current branch.

Git Status in Command Line

There are many tricks out there to get the git status to show in the command line path, but here’s one that worked the best for me on a Mac OS X Snow Leopard machine.
(more…)

JAR/XPI Firefox Extension Build Shell Script

I recently started work on a firefox extension, but this time I’m working on a mac rather than a pc. Below is a sample shell script for automatically building the JAR and XPI files.:

#!/bin/bash
mkdir build
mkdir build/chrome
cd chrome
zip -r formsaver.jar .
cd ..
cp chrome/formsaver.jar build/chrome/formsaver.jar
rm chrome/formsaver.jar
cp -R defaults build/
cp install.rdf build/install.rdf
cd build
zip -r formsaver.xpi .
mv formsaver.xpi ../formsaver.xpi
cd ..
rm -rf build
echo -n extension build successful

Here is a sample file for automatically building on windows (batch script):

Note: This requires that you have 7zip installed.

set x=%cd%
md build\chrome
md build\defaults\preferences
cd chrome
"C:\Program Files\7-Zip\7z.exe" a -tzip "%x%.jar" * -r -mx=0
move "%x%.jar" ..\build\chrome
cd ..
copy defaults\preferences\formsaver.js build\defaults\preferences
copy install.* build
cd build
"C:\Program Files\7-Zip\7z.exe" a -tzip "%x%.xpi" * -r -mx=9
move "%x%.xpi" ..\
cd ..
rd build /s/q

MySQL Backup Shell Script

Many of my clients need a quick backup solution before we implement anything on a larger more permanent scale. I wrote this simple script that simply make a copy of a database and then created a timestamped tarball of the file.

#!bin/sh

date=`date +%Y-%m-%d_%Hh%M`

cd /my/path/for/backups/

mysqldump -umy_user -p"mypass" my_database > $date.sql

tar -zcvf $date.tgz *.sql

# uncomment this line to import the sql into another database, for example as a mirror
#mysql -umy_user -p"mypass" mirror_database < $date.sql

rm *.sql

Then, just setup a cron job to run this at whichever interval you want this to run.