Wednesday, September 07, 2011

KeyRemap4MacBook Settings

I wanted to capture this somewhere in case I reinstall.  I use this to get my external keyboard to switch the command and option buttons (it's a windows keyboard) so it matches my muscle memory from a mac keyboard.


Tuesday, August 16, 2011

Debug a Unix Socket


socat - UNIX-CONNECT:/var/run/foo.sock

Tuesday, June 28, 2011

Delete Remote Git Tags By Pattern

git tag | grep release-2010 | xargs -n 1 -I % git push origin :refs/tags/%

Monday, January 17, 2011

God (process monitoring) RVM + init script

RVM
Here's how I got god working with rvm.
1. Install rvm for the system.
http://rvm.beginrescueend.com/deployment/system-wide/

2. Set up ruby and gemset.  Note that god doesn't play nicely with ruby-1.9.2-p136 but should play nice with the next release of 1.9.x.
rvm install ree
rvm use ree
rvm gemset create system
rvm use ree@system

3. Install god
gem install god

4. Create wrapper
rvm wrapper ree@system boot god

5. Make sure your init script uses /usr/local/rvm/bin/boot_god or use mine below.


6. Set default ruby.
For the system ruby:
rvm --default use system

For ree:
rvm --default use ree


7. Create your /etc/god.conf.  Make sure that you use rvm to wrap any binaries you need to run with a particular version of ruby or a particular set of gems (delayed_job is a good example).

Init Script
I wasn't happy with any of the init scripts I could find for God so I wrote my own.
This works with Fedora, RHEL, CentOS.

 #!/bin/bash
 #
 # God
 #
 # chkconfig: 2345 85 15
 # description: start, stop, restart God
 #
 # Also consider adding this line (kills god weekly) to your crontab (sudo crontab -e):
 #
 #    # deicide is painless
 #    0 1 * * 0 god quit; sleep 1; killall god; sleep 1; killall -9 god; sleep 1; /etc/init.d/god start
 #

 . /etc/rc.d/init.d/functions

 RETVAL=0
 prog="god"

 CONF="/etc/god.conf"
 PID_FILE="/var/run/god/god.pid" ; mkdir -p `dirname $PID_FILE`
 LOG_FILE="/var/log/god/god.log" ; mkdir -p `dirname $LOG_FILE`
 GOD="/usr/local/rvm/bin/boot_god"

 start()
 {
   echo -n $"Starting $prog: "
   $GOD -c "$CONF" -P "$PID_FILE" -l "$LOG_FILE" && success || failure
   RETVAL=$?
   echo
 }

 stop()
 {
   echo -n $"Stopping $prog: "
   kill `cat $PID_FILE` && success || failure
   RETVAL=$?
   echo
 }

 case "$1" in
     start)
       start
   ;;
     stop)
       stop
   ;;
     restart)
       stop
       start
   ;;
     status)
       status -p $PID_FILE $prog
       RETVAL=$?
   ;;
     *)
       echo "Usage: $prog {start|stop|restart|status}"
       exit 1
   ;;
 esac

 exit $RETVAL

Monday, December 13, 2010

Setting up iOS 4.2.1

I had 2 tasks worthy of a blog post.

1. Update Built-in Calendar Colors
In the past I've used sqlite running on the phone to do this but it's no longer available in Cydia. Instead I decided to use MacFUSE+Macfusion to mount the iphone's file system in mac os. I then used the great SQLite Manager addon for Firefox to open the calendar database file and make the changes from there.

2. Find applications to save/restore.
Here's the grep line I used to find the application data I wanted to save/restore.
cd ~mobile/Applications
grep -i "angry birds" */iTunesMetadata.plist

Friday, September 24, 2010

Homebrew!

I've just discovered homebrew!

http://mxcl.github.com/homebrew/

I've used it to install htop, wget, and hub (teaches git about github). It's already VASTLY superior to fink and ports.

.Xresources

Here's my final .Xresources before jumping ship to Terminal.app.

XTerm*background: black
XTerm*foreground: white
XTerm*scrollBar: false
XTerm*utf8: 1

xterm*saveLines: 10000
xterm*jumpScroll: true
XTerm*scrollBar: false

xterm*visualBell: true
xterm*loginShell: true

XTerm*VT100.Translations: #override \
Meta  W: quit() \n\
Meta  V: insert-selection(CLIPBOARD,PRIMARY,CUT_BUFFER0) \n\
: select-end(CLIPBOARD,PRIMARY,CUT_BUFFER0) \n\

Wednesday, July 14, 2010

Mac OS + XTerm + Copy/Paste

I've added the following snippet to my .Xresources file to get Command+V pasting from mac os apps. There are a few other customizations in there I'm still playing around with.

XTerm*VT100.Translations: #override \
 Prior: scroll-back(1,page) \n\
 Next: scroll-forw(1,page) \n\
Meta  W: quit() \n\
Meta  V: insert-selection(CLIPBOARD,PRIMARY,CUT_BUFFER0) \n\
: select-end(CLIPBOARD,PRIMARY,CUT_BUFFER0) \n\