Skip to content

Instantly share code, notes, and snippets.

View rajraj's full-sized avatar

Rajesh Rajappan rajraj

View GitHub Profile
@rajraj
rajraj / sublime_keybinings
Last active October 11, 2015 14:08
Sublime Text Keybinings
[
{ "keys": ["ctrl+shift+z"], "command": "insert_snippet", "args": {"contents": "<%= ${0:$TM_SELECTED_TEXT} %>"}, "context":
[
{ "key": "selector", "operator": "equal", "operand": "text.html, source.yaml, meta.erb" }
]
},
{ "keys": ["ctrl+alt+x"], "command": "insert_snippet", "args": {"contents": "<% ${0:$TM_SELECTED_TEXT} %>"}, "context":
[
{ "key": "selector", "operator": "equal", "operand": "text.html, source.yaml, meta.erb" }
]
@rajraj
rajraj / .bash_profile
Created March 29, 2012 07:25 — forked from henrik/.bashrc
Git branch and dirty state in Bash prompt.
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
# Edit .bash_profile
$ nano ~/.bash_profile
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
@rajraj
rajraj / gist:1834639
Created February 15, 2012 09:13
Backup and Restore MySql Database
# Backup Mysql database
$ mysqldump -u root -p contracts_production > contracts.sql
# Restore Mysql database from sql file
$ mysql -u root -p contracts_production < contracts.sql
@rajraj
rajraj / gist:1561091
Created January 4, 2012 17:28 — forked from lest/gist:1517325
Ruby 1.9.3 patched with readline and libyaml under rbenv
wget "ftp://ftp.cwru.edu/pub/bash/readline-6.2.tar.gz"
tar xf readline-6.2.tar.gz
cd readline-6.2
./configure --prefix=$HOME/.rbenv/versions/1.9.3-p0-patched
make -j 2
make install
cd ..
wget "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz"
tar xf yaml-0.1.4.tar.gz
@rajraj
rajraj / gist:1388849
Created November 23, 2011 14:46
Capybara Reference
# Credit: http://richardconroy.blogspot.com/2010/08/capybara-reference.html
#Navigating
visit('/projects')
visit(post_comments_path(post))
#Clicking links and buttons
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
@rajraj
rajraj / ubuntu
Created November 3, 2011 19:46
Ubuntu System Setup
#!/usr/bin/env bash
# bash < <(curl -s https://???)
echo "Checking for SSH key, generating one if it exists ..."
[[ -f ~/.ssh/id_rsa.pub ]] || ssh-keygen -t rsa
echo "Copying public key to clipboard. Paste it into your Github account ..."
[[ -f ~/.ssh/id_rsa.pub ]] && cat ~/.ssh/id_rsa.pub | xclip
open https://github.com/account/ssh
$(function(){
// Collect all text boxes
$textboxes = $(":text");
// call checkForEnter function when a key is pressed
$textboxes.keydown(checkForEnter);
// This function checks if the Enter key is pressed
// If yes then moves the cursor to the next box
function checkForEnter(event) {
@rajraj
rajraj / rapleaf.rake
Created March 17, 2011 22:45
Rapleaf Name to Gender API
namespace :ycpages do
desc "Update person gender using RapLeaf's name to gender API."
task :update_gender => :environment do
Person.all.each do |person|
unless person.gender.present?
url = "http://api.rapleaf.com/v4/util/name_to_gender/#{person.name.split.first}"
response = Net::HTTP.get_response(URI.parse(url))
result = JSON.parse(response.body)
if ((result["status"] == "OK") && (result["answer"]["likelihood"].to_f > 0.9))
person.update_attribute(:gender, result["answer"]["gender"])
echo off
REM cd into your rails app folder
cd e:\webapps\projects
REM Then Call the rake task
call rake trant:send_notification
namespace :trant do
desc "Send email notifications for a project."
task :send_notification => :environment do
Project.send_notification
end
end