script to update AirMail Beta

AirMail Beta is updated so frequently that I am getting quite annoyed by having to download and extract and copy the new build from the same link over and over again. So here’s a no-brainer bash script which does these repetitive manual actions.

#!/bin/bash
echo "downloading airmail.zip"
wget $(curl -L http://airmailapp.com/beta 2>/dev/null | grep 'format=zip' | head -1 | cut -d\' -f4) -O airmail.zip
 
if [[ -d "AirMail Beta.app" ]]; then
    rm -rf "AirMail Beta.app"
fi
 
echo "unzip airmail.zip"
unzip airmail.zip 2>&1 1>/dev/null
 
PID=$(ps -A | grep "AirMail Beta" | grep -v grep | awk {'printf $1}')
if [[ ! -z ${PID} ]]; then
    echo "kill running airmail (${PID})"
    kill ${PID}
fi
 
if [[ -d "/Applications/AirMail Beta.app" ]]; then
    echo "rename current airmail.app"
    mv "/Applications/AirMail Beta.app" "/Applications/AirMail Beta old.app"
fi
 
echo "copy new airmail.app to applications directory"
mv "AirMail Beta.app" /Applications/
 
echo "cleanup"
rm airmail.zip
rm -rf "/Applications/AirMail Beta old.app"
 
if [[ ! -z ${PID} ]]; then
    echo "restart airmail.app"
    open -g "/Applications/AirMail Beta.app"
fi
echo "done"

pwd#

Chrome extension based on PwdHash 1.7

Usage:

  • press ctrl+\ to fill in all password input on page, page doesn’t necessarily need to be completely loaded
  • double click on a filled password input to show unmasked password

Click here to install
Source is available at here

Add dropbox cli as a daemon on ArchLinux

Dropbox can be used as a free cloud backup solution but in order to do so, dropbox has to be added as a service/daemon, simply save the following script as dropboxd in /etc/rc.d/

#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

USER=YOUR_USER_NAME
DROPBOXD=/home/$USER/.dropbox-dist/dropboxd
PID=$(pidof -o %PPID $DROPBOXD)
case "$1" in
  start)
    stat_busy "Starting dropboxd"
    [ -z "$PID" ] && sudo -u $USER $DROPBOXD &
    if [ $? -gt 0 ]; then
      stat_fail
    else
      add_daemon dropboxd
      stat_done
    fi
    ;;
  stop)
    stat_busy "Stopping dropboxd"
    [ ! -z "$PID" ]  && kill $PID &> /dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      rm_daemon dropboxd
      stat_done
    fi
    ;;
  restart)
    $0 stop
    sleep 1
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"
esac
exit 0

Now add dropboxd to the daemon list in /etc/rc.conf and voila!

Changed hosting

Finally, I have my own VPS on linode now! Yeehoo~
Since moved to linode, the website is responding noticeably slower and this is the only drawback I’ve noticed so far.
But who visit here anyways. 😀

桜

春・桜

Accidentally saw this cherry tree full of blossoms on the metro, I couldn’t help but got off the metro right away and took this picture with my iphone, so please pretend that you don’t notice the poor quality :p