Using Google Adwords to max out Dropbox referrals

I stumpled upon Vladik Rikhter’s post via Hacker News on how to utilize Google Adwords to max out your Dropbox referrals for less than $10. Basically, you set up an ad campaign that leads people to sign up for a Dropbox account via your referral link, giving them 2.25 GB (250 MB extra for using a referral link) of free storage while you benefit 250 MB (or 500 MB if your account is linked to your school email). My initial attempt at this did not yield any clicks, probably because many people were following this method. I waited two weeks and I still didn’t get any referrals; this was probably brought forth by the publicity generated by Lifehacker’s post (see this too). After about 3 months of waiting, I raised my max bid to $0.10/click, and I got 5 referrals in a 24 hour period. I then raised my max bid to $0.20/click and I completed my quota in a day (I’m at 18.3 GB right now with my student email linked to my account). My total cost was $5.34 since I had many referrals prior to using the campaign (was at 9.3 GB). FYI, the default auto bid was around $0.14/click, so this amount should give you enough referrals in a 24 hour period.

Note to self: use Google Adwords when I need people to click on a link (e.g., for referrals).

Some modifications for WordPress

I recently changed my WordPress theme to Reflex+, a theme that resembles the current look of Google+ and other Google related services. I had to make some manual modifications.

Excerpt vs. full content for each post

On the main index page, you can either show just an excerpt or the full content of each post. I like the full content. To get the index page of your current theme to show the entire content of each post, find a line in ./blog/wp-content/themes/reflex-plus/index.php similar to


and change it to


My changes:

»').''); */ /*vinh: display full content instead of summary */?>
»').''); ?>

Edit link style

I don’t like it when links are not visually different than normal text. I followed this post and modified ./blog/wp-content/themes/reflex-plus/style.css: a:link {
color: #09C;
} a:visited {
color: #006;
text-decoration: none;

Adding instructions or comments to the comments section

I wanted to give instructions on writing Markdown Syntax, source code, and LaTeX near the comments box. I modified ./blog/wp-includes/comment-template.php as follow:

/* 'comment_notes_after' => '

' . sprintf( __( 'You may use these HTML tags and attributes: %s' ), ' =' . allowed_tags() . '=' ) . '

', */ /* vinh */
'comment_notes_after' => '

Use [[][Markdown Syntax]] for markup.
Surround blocks of code with 
. For syntax highlighting of specific languages, use the appropriate "brush alias" from [[][this]] list. For example, surround php code with
. LaTeX code can be surrounded by "backslash left parenthesis" and "backslash right parenthesis" or "backslash left square bracket" and "backslash right square bracket". ',

Google CloudPrint on Linux

Google CloudPrint allows users to print to the cloud from devices such as your mobile phone. That is, you can print documents and pictures from your phone to printers you have access to (e.g., at home) but is not directly connected to your phone. As of 5/12/2011, only printing from mobile Gmail and Google Docs (from the browser) are supported besides the Chrome OS. Also, only printers that are accessible to computers running Windows or Mac with the Chrome browser installed are supported. What about Linux? This thread points to the cloudprint python program. I installed it and have it started at startup via the following:

 <pre class="src src-sh">git clone

sudo apt-get install python-pip sudo pip install daemon sudo python install ## or skip the whole git process and do: sudo pip install cloudprint ## place content daemon script in /etc/init.d/cloudprint sudo chmod +x /etc/init.d/cloudprint

where the daemon script was adapted from this:

<pre class="src src-sh"><span style="color: #ff4500;">#</span><span style="color: #ff4500;">!/bin/</span><span style="color: #00ffff;">bash</span>

# /etc/rc.d/cloudprint # Description: Starts the Google Cloud Print script on startup # —————- # ### BEGIN INIT INFO # Provides: Cloud-Print # Required-Start: $cups $network $local_fs $syslog # Required-Stop: $local_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Description: Start Google Cloud Print ### END INIT INFO

case $1 in start) echo -n “Starting Google Cloud Print: “ ##/root/cloudprint/ sudo -u vinh cloudprint -d ;; stop) echo -n “Stopping Google Cloud Print: “ ##killall ;; restart) # echo -n “Restarting Google Cloud Print: “ ##killall ##/root/cloudprint/ killall cloudprint sudo -u vinh cloudprint -d ;; # echo “Usage: cloudprint {start|stop|restart}” esac

Then, add it to the startup list: sudo update-rc.d cloudprint defaults.

Make sure you log in manually at least once so that you can enter your username and password.

UPDATE 5/19/2011: I modified the init script so that I can print from a particular user. That way, if I print to cups-pdf, my files will be in ~/PDF/. When cloudprint is run as root, I don’t know where the PDF’s generated from cups-pdf are. The README and /etc/cups/cups-pdf.conf documentation states that outputs are always in $HOME/PDF, and anonymous files are stored in /var/spool/cups-pdf/ANONYMOUS. However, I do not see the files in these locations. Therefore, I will just run cloudprint as my myself instead of root.

Also, I discovered PrinterShare, a pretty useful printing app for Android devices.

UPDATE 4/2/2012: You actually need to hard code your google credentials in order for the daemon to work (path: /usr/local/lib/python2.7/dist-packages/cloudprint-0.5-py2.7.egg/cloudprint/ As I did not want to expose my credentials, I created a new gmail account dedicated to CloudPrint. I hard code these credentials, and add the google account to my Android device.

Backup your gmail account in Linux/Unix or Mac OS X using getmail

Even though I have utmost trust in Google’s data centers (>= 99.9% uptime), I finally decided to backup my gmail account. I am pretty OCD when it comes to backing up my data (bi-weekly backups of my home directory into 3 external hard drives, one of which is in a water/fire-proof safe box; MOST important research-related files in the cloud via dropbox), but I’ve never backed up my mail archive which holds a lot of valuable information.

I googled it before but never got around to doing it. Finally, I’ve implemented my backup scheme, thanks to this, this, and this.

The main program that does the work is getmail. To install, issue the following in Debian (apt-get) or Mac OS X (Macports):

 <pre class="src src-sh"><span style="color: #ff4500;">## </span><span style="color: #ff4500;">Debian</span>

sudo apt-get install getmail4 ## Mac OS X via macports sudo port install getmail

mkdir ~/.getmail mkdir ~/Backup/gmail-archive emacs -q -nw ~/.getmail/

Put the following in “~/.getmail/” (use IMAP and save both an mbox and a maildir version of my gmail account):

 <pre class="src src-sh">[retriever]

type = SimpleIMAPSSLRetriever server = username = email.address password = my.password mailboxes = (“[Gmail]/All Mail”,) [destination] type = MultiDestination destinations = (‘[mboxrd-destination]’, ‘[maildir-destination]’)

[mboxrd-destination] type = Mboxrd path = ~/Backup/gmail-archive/gmail-backup.mbox

[maildir-destination] type = Maildir path = ~/Backup/gmail-archive/

[options] # print messages about each action (verbose = 2) # Other options: # 0 prints only warnings and errors # 1 prints messages about retrieving and deleting messages only verbose = 2 message_log = ~/.getmail/gmail.log # preserves your mail after backup delete = false # just get new mails read_all = false

Note the “read_all” option – without this, getmail downloads multiple versions of the mail and the hard drive will fill. This happened to me!

In the shell, type

<pre class="src src-sh">touch ~/Backup/gmail-archive/gmail-backup.mbox

mkdir ~/Backup/gmail-archive/tmp ~/Backup/gmail-archive/new ~/Backup/gmail-archive/cur getmail -r $HOME/.getmail/

To set a cron job for midnight, create the following and place it in cron via “cron -e”:

<pre class="src src-sh">

#!/usr/bin/env bash # Note: -q means fetch quietly so that this program is silent /usr/bin/getmail -q -r $HOME/.getmail/

chmod u+rx $HOME/Backup/

crontab -e: 00 00 * * * $HOME/Backup/

Using Google My Maps: planning my stay in San Francisco

So I have to be in SF for an internship this summer. As with all relocation there is the hassle of finding a place to live. After googling to find a suitable apartment, I realized that Craig’s list is the best place to go. I tried to avoid it at first since I just wanted to deal with apartment managers, but I realized that many apartment managements are bad (the reviews!). I thus resorted to Craig’s List (temporary and sublets) and housing options information from UCSF, such as this. Finding a place to live is a bitch because I won’t have a car (rely on public transportation). Thus I have to get a place that is close to public transportation stops (thank goodness public transportation in SF is great), especially close to where the company-sponsored bus stops are at. After finding an ad, looking up a location, weigh in a bunch of information (furnished, rent, utilities, etc), comparing it to bus stops, things got out of hand. I needed a program/service that plot out multiple locations. Google Maps came to the rescue! I used the My Maps feature (click on it), created a private map, plot out where the bus stops (company) are, 24 hour fitness, gyms, costco, etc. Next, each potential housing option, I saved it, along with it’s link (eg, craigslist) and additioinal information. This made the job a little easier (housing hunting is always a bitch!). Be sure to google or find out where the bad neighborhoods are, eg, tenderloin in SF.

create online store easily: google docs + google sites + google checkout

so i have so many things on my to do list, so i’ll just get this post out of the way while i can….it’s ‘old’ in that i’ve known about this last month but didn’t blog about it yet.

google made it very easily to create an online store. u can set up a spreadsheet in google docs (inventory), embed the google checkout gadget in your google site, and u have an online store. see here for a how to.

i was thinking about using this to create an online registration program for my youth group, but google collects a fee, so it probably isn’t worth it for my non-profit group.

one of the downside (?) to this is u need a google checkout account…hmm…but i think this is better than paypal.

Backup my google calendars via shell and python scripts and scheduling them via cron

So recently my calendar got messed up a little (dupes) due my mobile phone (HTC Touch Pro running Windows Mobile 6.1) resetting [syncing again messed it up]. I realize (now???) I need to keep backups of my calendars and contacts.

I took the following script online (which requires python and the gdata module):

<pre class="src src-sh"><span style="color: #ff4500;">#</span><span style="color: #ff4500;">! /usr/bin/</span><span style="color: #00ffff;">python</span>

## This script backs up my google contacts ##

import gdata.contacts.service gd_client = gdata.contacts.service.ContactsService() gd_client.ClientLogin(‘’, ‘password’) query = gdata.contacts.service.ContactsQuery() query.max_results = 2000 # change for max contacts returned feed = gd_client.GetContactsFeed(query.ToUri()) print feed

and adapted the following script to backup my calendars and contacts:

 <pre class="src src-sh"><span style="color: #ff4500;">#</span><span style="color: #ff4500;">! /bin/</span><span style="color: #00ffff;">bash</span>

## This script backs up my calendars — will use with Cron to backup daily. ## following is adapted from INCREMENT=date +%Y%m%d%H%M DIR=“$HOME/Documents/Backup_Google” USERNAME=“” PASSWORD=“mypassword” ## Vinh’s calendar curl -s url-to-private-ics -o “$DIR/Vinh_$INCREMENT.ics” ## TNTTSP’s calendar’ curl -s url-to-private-ics -o “$DIR/TNTTSP_$INCREMENT.ics” ## Birthdays curl -s url-to-private-ics -o “$DIR/Birthdays_$INCREMENT.ics”

## Now backup Google Contacts ## $HOME/Documents/bin/ > ${DIR}/VinhContacts_$INCREMENT.xml

## Now backup Google Reader subscriptions ## $HOME/Documents/bin/ $USERNAME $PASSWORD > Vinh_GoogleReaderSubs_$INCREMENT.opml

find $DIR -mtime +14 -exec rm -f {} \;

Every time the script runs, it backs up my 3 calendars and contacts. The very last line says delete if files are 14 days or older.

Now, to set up my crontab to run this everyday at 10pm, I type “crontab -e” in the shell. I put

<pre class="src src-sh">00 22 * * * $<span style="color: #eedd82;">HOME</span>/Documents/bin/

when vi (or your default visual editor) opens up.

More info about cron on the Mac is here.

Sometimes, you might not want to schedule a recurring script. To run a script once, we can rely on the at (“at”) command. More information here and here. However, the at command didn’t work on my Macbook when I tried it a while back.

UPDATE: The script above ( is updated to include the google reader subscription, thanks to this site.

the next big thing from google: WAVE

Google just recently unveiled Google WAVE (keynote presentation at Google I/O 2009). I read it on the news, googled it, went to the blog, and watched the video.

The video is quite long (1+hr, 300+mb). I downloaded it and viewed it. Looks like it is Google’s next big product. Email has been invented for 40+ years. They are attempting to re-invent email as if it were invented in today’s time. As always, based on cloud computing (hosted by google), uses html5 as the platform. It combines email, photos, IM, discussion board, etc., all into one interface. The API is going to allow other sites to embed and use it as well. Super cool!

Google gadgets

One thing I’ve recently discovered about Google are the gadgets. I knew they existed, but I don’t use the iGoogle page that often for me to use them. However, I use gmail 24/7, so I added some there. They even have gadgets for Blogger.