Skip to content

Instantly share code, notes, and snippets.

View grahamg's full-sized avatar

Graham Greenfield grahamg

View GitHub Profile
@grahamg
grahamg / lisp.rb
Created September 4, 2010 20:30 — forked from dahlia/lisp.rb
# 30 minutes Lisp in Ruby
# Hong MinHee <http://dahlia.kr/>
#
# This Lisp implementation does not provide a s-expression reader.
# Instead, it uses Ruby syntax like following code:
#
# [:def, :factorial,
# [:lambda, [:n],
# [:if, [:"=", :n, 1],
# 1,
/* begin table creation */
create table department
(dept_id smallint unsigned not null auto_increment,
name varchar(20) not null,
constraint pk_department primary key (dept_id)
);
create table branch
(branch_id smallint unsigned not null auto_increment,
(function (a) {
a.browserTest = function (e, g) {
var f = "unknown",
d = "X",
b = function (k, j) {
for (var c = 0; c < j.length; c = c + 1) {
k = k.replace(j[c][0], j[c][1])
}
return k
},
import urllib, urllib2
def getsource(pagereq):
user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
header = {'User-Agent': user_agent}
req = urllib2.Request(pagereq, None, header)
response = urllib2.urlopen(req)
page = response.read()
return page