Skip to content

Instantly share code, notes, and snippets.

@chanian
chanian / MyRobot.c
Created December 1, 2010 03:27
Afternoon hack, and relearning C. Find all paths of the dummy robot on a nxn grid.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
int size;
int size_minus_1;
struct move {
int x;
@chanian
chanian / TQINAT.c
Created December 1, 2010 04:49
TQINAT: (T)his (Q)uine (I)s (N)ot (A) (T)QINAT
#define B(x) x; printf("{ B(" #x ") }\n");
int main()
{ B(printf("#define B(x) x; printf(\"{ B(\" #x \") }\\n\");\nint main()\n")) }
@chanian
chanian / gitbranch.sh
Created December 2, 2010 20:55
Painless feature branch creation for all!
#!/bin/sh
if [ ! -d ./.git ]
then
echo "Not a git repository"
exit
fi
if [ $# -ne 1 ]
then
echo "Please provide a branch name to create and switch to"
exit
@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}")
@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 / 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 / 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 / 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 / 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 / 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