Skip to content

Instantly share code, notes, and snippets.

@rohitnjan88
rohitnjan88 / print_numbers.rb
Created March 24, 2012 13:17
a script to output integers periodically
i = 0
loop {
puts i
i += 1
sleep(1)
}
@rohitnjan88
rohitnjan88 / dep.sh
Created March 13, 2012 21:54 — forked from revathskumar/dep.sh
Installing Feedzirra
sudo apt-get install libcurl4-openssl-dev libxml2 libxslt-dev
@rohitnjan88
rohitnjan88 / dep.sh
Created March 13, 2012 21:54 — forked from revathskumar/dep.sh
Installing Feedzirra
sudo apt-get install libcurl4-openssl-dev libxml2 libxslt-dev
@rohitnjan88
rohitnjan88 / stackoverflow.c
Created February 19, 2012 18:09
StackOverFlow
void foo( int i ) {
char temp[ 1024 * 1024 ]; //1Mb of memory will be allocated from the stack-frame
printf (” %d n”, i );
foo ( i + 1 );
}
int main() {
foo( 1 );
}
@rohitnjan88
rohitnjan88 / ackermann_function.py
Created February 19, 2012 18:02
Ackermann Function
def A( m, n ):
if m == 0:
return n + 1
elif n == 0:
return A ( m - 1, 1 )
else:
return A ( m - 1, A ( m, n - 1 ) )
@rohitnjan88
rohitnjan88 / repl
Created December 15, 2011 09:58
basic prefix expression evaluation
require 'rubygems'
require 'json'
def tokenize( str )
return str if str.count('(') == 0
str = str.gsub('(',' ( ').gsub(')',' ) ').split(' ')
end
def build_tree(list)
return list unless list.is_a? Array
@rohitnjan88
rohitnjan88 / gist:1375927
Created November 18, 2011 08:42
Koch Snow Flake (recursive flake function)
def flake(self,length):
if length <10:
self.move_forward(l)
self.c.update()
return
else:
self.flake(length/3)
self.rotate_left(60)
self.flake(length/3)
from Tkinter import *
from math import *
from time import *
class TurtleClass(object):
"""a turtle class """
def __init__(self,c):
self.x,self.y,self.d=100,300,0
self.c = c
self.l1,self.l2,self.l3 = 0,0,0
@rohitnjan88
rohitnjan88 / LICENSE.txt
Created September 29, 2011 11:58 — forked from p01/LICENSE.txt
Sudoku Solver in 140bytes
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Mathieu 'p01' Henri <http://www.p01.org/releases/>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@rohitnjan88
rohitnjan88 / 0_memprof_ruby-v
Created August 11, 2011 19:43
680 String left in memory after GC.start ???!
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
680 test.rb:8:String
1 test.rb:8:Process::Status
1 test.rb:8:Array
memprof (0.3.10)