Tuesday, February 18, 2014

Set up canonical url for A/B test page variations

Say you have 2 page variations for an A/B test. Page A (original) - /home Page B (variation) - /home_variation In order for Google spiders to only pick up contents in Page A since it has already been crawled and SEO-ed and we don't want Page B to affect SEO rankings, we need to specify in Page B that the url to Page A is canonical, ie. the main url.

Saturday, February 8, 2014

Export queried data from MySQL in bash command line


SELECT distinct(users.email), users.firstname INTO OUTFILE '~/Downloads/users.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' FROM users;

Monday, November 25, 2013

Send/write code in Gmail emails

Use this chrome extension to write the code snippet in Markdown, toggle convert snippet to HTML and send. Win! https://chrome.google.com/webstore/detail/markdown-here/elifhakcjgalahccnjkneoccemfahfoa

Friday, November 15, 2013

Checkout version of a file in previous git commit


# This rolls back the diff of the file in the git commit
git checkout COMMIT_SHA FILE

# Commit the file modification (rolled back diff)
git add FILE
git commit -m "Check out previous version of file." 

Thursday, November 14, 2013

Get large facebook profile picture from facebook id.

Just use the following url format for your image tag.

http://graph.facebook.com/FACEBOOK_ID/picture?type=large

Friday, February 15, 2013

Crop center and resize paperclip image attachment


  has_attached_file :profile_image,
    storage: :s3,
    s3_credentials: {
      bucket:            Settings.s3_bucket_name,
      access_key_id:     Settings.aws_access_key_id,
      secret_access_key: Settings.aws_secret_access_key
    },
    default_url: '/assets/default_profile_pic.png',
    styles: { square_50: '', square_100: '', square_193: '' },
    convert_options: {
      square_50: '-gravity center -resize 50x50^ -crop 50x50+0+0',
      square_100: '-gravity center -resize 100x100^ -crop 100x100+0+0',
      square_193: '-gravity center -resize 193x193^ -crop 193x193+0+0'
    }

Thursday, February 7, 2013

Restart Nginx on OSX

Best to have them as bash aliases.

alias startnginx='sudo /usr/local/Cellar/nginx/1.2.4/sbin/nginx'
alias stopnginx='sudo killall nginx'
alias restartnginx='stopnginx; startnginx'

# If you need to know where's nginx bin
locate nginx