Skip to content

Instantly share code, notes, and snippets.

@chanian
chanian / gitwho.sh
Created August 9, 2012 03:33
more git stats on a specific file
# chuck this in your ~/.local.bash or ~/.bash_profile
# usage: gitwho filename
function gitwho() {
echo -e "\n File: $1";
echo -n " Last Commit:";
echo -e "\033[35m \c";
git log --relative-date --pretty='%aN (%ad)' -n1 $1;
echo -e "\033[35m \c";
echo -n " - ";
git log -n1 --format="%s" $1;
@chanian
chanian / gitchanges.sh
Created May 10, 2012 22:59
Show me what I've changed
alias gitchanges='git diff origin/master | grep "+++" | cut -d" " -f2'
@chanian
chanian / gist:1824471
Created February 14, 2012 07:21
that thing
/^(\".+\")=(\".+\")$/.test('":n\"ame"="value"')
console.log(RegExp.$1, RegExp.$2)
@chanian
chanian / gist:1731922
Created February 3, 2012 19:31 — forked from xchoi/gist:1516166
Asian name generator
%w(a e i o u).map {|x|
['', 'a', 'e', 'i', 'o', 'u'].map {|y|
['', 'n', 'ng'].map {|z| (x!=y) ? 'ch' + x + y + z : nil }
}
}.flatten.uniq.compact
@chanian
chanian / ie-console.js
Created November 10, 2011 00:43
make IE<=7 slightly less painful
(function () {
if(!window.console) {
console = {
log: function() {
var str = "";
for(var i = 0; i < arguments.length; i++) {
str += arguments[i];
}
document.body.appendChild(document.createTextNode(str));
document.body.appendChild(document.createElement('br'));
@chanian
chanian / imax.sh
Created June 16, 2011 18:52
Was that movie originally filmed in IMAX? Or am I paying extra for good marketing...
#!/bin/sh
#
# usage: ./imax.sh "tron 2"
#
# Note, this doesn't always work as it is clearly scrapping imdb.
# comment below for any suggested changes!
#
echo "Was it filmed in IMAX?"
q=`echo $1 | sed -e s/\ /\+/g`
@chanian
chanian / iesupport.js
Created April 27, 2011 22:30
a simple script, should be used by all
if(!!navigator.userAgent.match('MSIE') && Math.floor(navigator.appVersion) === 6) {
alert("suckit...");
}
@chanian
chanian / HelloWorld.rb
Created April 14, 2011 21:03
The most straight forward hello world example I could think of...
class Foo
def self.foo(*args)
args.each { |arg|
print arg[arg.keys.first]
}
yield
end
end
puts Foo.foo({:beep => "hello"},{:word=>" "}){x={:word => "world"};Foo.foo({:word => "there"},{:word => " "}){{:hello =>{:there=>{:world =>x[:word]}}}}}[:hello][:there][:world]
@chanian
chanian / qunit_test.js
Created April 12, 2011 01:33
toooo slow!
QUnit.done = function(qunitReport) {
console.log(qunitReport.total);
};
setTimeout(function() {
test("helloworld", function() {
expect( 1 );
ok(true);
});
}, 100);
@chanian
chanian / digg.rb
Created January 24, 2011 02:10
A method to retrieve the digg counts of a URL
require 'rubygems'
require 'json'
require 'open-uri'
# All your diggs, are belong to me
# I'm sure there is a better way, but this is a simple unauthenticated
# pull of digg counts for a URL. No bells.. No whistles..
def getDiggs(url)
begin
response = open("http://widgets.digg.com/buttons/count?url=#{url}")