shell scripts
Quickly starting django development server on local IP
I am frequently running ./manage.py runserver SOME_IP:8000 , so I can run django dev on my local IP address, so it can be accessed by other computers on the network for testing. Here's a shell script to automate the steps it takes to do that:
#!/bin/bash
# virtualenv
source bin/activate
# get the local IP
IP=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'`;
# write the IP for use in settings module
echo "IP='$IP'" > local_settings_ip.py
# launch window in firefox ( will need to refresh )
firefox http://$IP:8000
recursive sed excluding svn files
replace string1 with string2, recursively:
find ./ -path '*/.svn' -prune -o -type f -exec sed -i "s/string1/string2/g" {} \;batch converting Nikon .NEF images to greyscale JPG
Run this in a directory of .NEF files to
* create a directory "mkdir bw-jpg-greyscale-lightness"
* convert each image to black and white with auto exposure, colors, white-balence, etc.
* save each image as a JPG to the "mkdir bw-jpg-greyscale-lightness" directory
Written by yours truly
#!/bin/sh
mkdir bw-jpg-greyscale-lightness;
for file in *.NEF;
do ufraw-batch $file --out-path=bw-jpg-greyscale-lightness --wb=auto --exposure=auto --black-point=auto --color-smoothing --grayscale=lightness --out-type=jpg;
donelinux tar simple example
OK, this is really simple, but I'm always forgetting the exact syntax, and man pages are overkill for this.
Tar a directory "dir" into a gzip'd tarball:
tar -zcvf dir.tar.gz dirAnd extract it:
tar -zxvf dir.tar.gzsimple sed example
This will globally find and replace all instances of "find" with "replace"
$ sed -i 's/find/replace/g' file.txtUbuntu lucid: downgrading to php 5.2
I'm attaching the shell script I used to do this...Slightly modified from other variations online. Obviously don't run this without understanding it- it will remove your existing php packages
Then if you need to install any additional php packages, just install them with ( notice the -t karmic option )
sudo aptitude install -t karmic php5-mysql php5-xdebug phpmyadminFor more info:
http://jtrancas.wordpress.com/2010/05/04/cakephp-1-1-and-php-5-3/
http://ubuntuforums.org/showthread.php?t=1459163&page=2
adding aliases the easy way
I'm always forgetting the syntax..
echo "alias drush='~/drush/drush'" >> ~/.bash_profile
source ~/.bash_profileGREP sans SVN
Here's a quickie to do a recursive grep, ignoring SVN files:
grep --exclude=\*.svn\* -r "my_string_here" .Curl your Drupal modules
Why bother to download, unzip, and stick in your modules dir?
Just cd sites/all/modules and do this:
curl http://ftp.drupal.org/files/projects/tinytax-6.x-1.11.tar.gz|tar -xzf -and replace "tinytax-6.x-1.11" with whatever the module is, obviously...
OR - if you're feeling really slick - use drush, then just run php-cli path/to/drush/drush.php pm install module_name
Removing all .svn directories
HOWTO Recursively remove all svn directories from a directory... yay I love shell scripting. BE CAREFUL WITH THIS!!
find . -type d -name ".svn" -exec rm -rf {} \;