This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'hpricot' | |
require 'net/http' | |
blog = 'www.paulgraham.com' | |
out_dir = '/home/ananth/paul/' | |
url = URI.parse('http://paulgraham.com/articles.html') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; style your emacs with css | |
(setq source " | |
frame { | |
foreground-color : wheat; | |
background-color: darklategrey; | |
background-mode : dark | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;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)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'}; | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define lat? | |
(lambda (l) | |
(cond | |
((null? l) #t) | |
((atom? (car l)) (lat? (cdr l))) | |
(else #f)))) | |
(define atom? | |
(lambda (x) |