Skip to content

Instantly share code, notes, and snippets.

View anagri's full-sized avatar

Amiruddin Nagri anagri

View GitHub Profile
<key>JVMCapabilities</key>
<array>
<string>CommandLine</string>
</array>
function formatCurrency(number) {
var numberStr = number.toString();
var thousandsMatcher = /(\d+)(\d{3})$/;
var thousandsAndRest = thousandsMatcher.exec(numberStr);
if (!thousandsAndRest) return numberStr;
return thousandsAndRest[1].replace(/\B(?=(\d{2})+(?!\d))/g, ",") + "," + thousandsAndRest[2];
}
git config --global user.email amir.nagri+git@gmail.com
git config --global user.name "Amiruddin Nagri"
git config --global color.ui auto
git config --global alias.cp = cherry-pick
git config --global alias.st status
git config --global alias.co checkout
git config --global alias.dc "diff --cached"
git config --global alias.br branch
git config --global alias.dlc "diff --cached HEAD^"
@anagri
anagri / mysql_config
Created August 30, 2013 06:28
Setting up mysql2 gem on Mac OS X
cflags="-I$pkgincludedir -Wall -Os -g -fno-strict-aliasing -DDBUG_OFF -arch x86_64 " #note: end space!
cxxflags="-I$pkgincludedir -Wall -Os -g -fno-strict-aliasing -DDBUG_OFF -arch x86_64 " #note: end space!
@anagri
anagri / openInITerm
Created August 1, 2013 06:30
Applescript to Open Selected Folder in iTerm
tell application "Finder"
set myWin to window 1
set theWin to (quoted form of POSIX path of (target of myWin as alias))
tell application "iTerm"
make new terminal
tell the first terminal
activate current session
launch session "Default Session"
tell the last session
write text "cd " & theWin
@anagri
anagri / gist:1579614
Created January 8, 2012 20:41
ruby warrior
class Player
def play_turn(warrior)
if @backward.nil?
if warrior.feel(:backward).captive?
warrior.rescue!(:backward)
elsif warrior.feel(:backward).empty?
warrior.walk!(:backward)
else
@backward = true
warrior.walk!
@anagri
anagri / validate.js
Created June 20, 2011 10:45
validation framework
;
var validator = $('form').expValidate({
rules: {
cityname: 'required',
checkinDate: ['required', 'date'],
checkoutDate: ['required', 'date']
},
groups: {
dateRange: ['checkinDate', 'checkoutDate']