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

Friday, January 18, 2013

Permission denied (publickey) error when doing cap deploy

I encountered this when trying to do a capistrano deploy on one of client's server. This error means that the server that's trying to fetch from repository on Github does not have permission to do so. We can resolve this with either:


If ssh-agent isn't running, run the following in terminal.

exec ssh-agent bash