Skip to content

Instantly share code, notes, and snippets.

View ananthakumaran's full-sized avatar

Anantha Kumaran ananthakumaran

View GitHub Profile
require 'rubygems'
require 'hpricot'
require 'net/http'
blog = 'www.paulgraham.com'
out_dir = '/home/ananth/paul/'
url = URI.parse('http://paulgraham.com/articles.html')
;; style your emacs with css
(setq source "
frame {
foreground-color : wheat;
background-color: darklategrey;
background-mode : dark
}
@ananthakumaran
ananthakumaran / blog_grabber.rb
Created April 23, 2010 17:49
grabs the posts of steve yegge
# grabs all the post from steve-yegge blog
require 'net/http'
require '/home/ananth/.gem/ruby/1.8/gems/xml-simple-1.0.12/lib/xmlsimple'
blog = 'www.blogger.com'
out_dir = '/home/ananth/steve-yegge/'
proxy_host = 'proxy.karunya.edu'
proxy_port = 3128
;;How many different ways can we make change of $ 1.00, given half-dollars, quarters,
;;dimes, nickels, and pennies? More generally, can we write a procedure to compute
;;the number of ways to change any given amount of money?
(define (count-change amount)
(cc amount 5))
(define (cc amount kinds-of-coins)
(cond
((= 0 amount) 1)
;;A function f is defined by the rule that f(n) = n if n<3 and f(n) = f(n - 1) + 2f(n - 2) + 3f(n -3)
;;if n> 3. Write a procedure that computes f by means of a recursive process. Write a procedure that
;;computes f by means of an iterative process.
(define (f n)
(cond
((< n 3) 0)
(else
(iter-fun n 0 1 2))))
@ananthakumaran
ananthakumaran / cube.ss
Created April 21, 2010 06:41
SICP ex 1.8
;; finds the cube root of a number using newton method
(define cube
(lambda (x)
(cube-iter 1.0 x)))
(define cube-iter
(lambda (guess x)
(if (good-enough? guess x)
guess
@ananthakumaran
ananthakumaran / sqrt.ss
Created April 21, 2010 06:38
SICP ex 1.7
;; finds the sqrt of a number using newton's method
(define sqrt
(lambda (x)
(sqrt-iter 1.0 x)))
(define sqrt-iter
(lambda (guess x)
(if (good-enough? guess x)
guess
public static byte[] readFully(InputStream input) throws IOException {
byte[] buffer = new byte[8192];
int bytesRead;
ByteArrayOutputStream output = new ByteArrayOutputStream();
while ((bytesRead = input.read(buffer)) != -1) {
output.write(buffer, 0, bytesRead);
}
return output.toByteArray();
}
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class HashService {
public static char[] HEX_CHARS = new char[] {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D',
'E', 'F'};
/**
(define lat?
(lambda (l)
(cond
((null? l) #t)
((atom? (car l)) (lat? (cdr l)))
(else #f))))
(define atom?
(lambda (x)