Skip to content

Instantly share code, notes, and snippets.

View bartschuller's full-sized avatar

Bart Schuller bartschuller

View GitHub Profile
@bartschuller
bartschuller / scala transcript.txt
Created January 17, 2011 22:42
My new Scala Mechanize library is taking shape
scala> val agent = new org.smop.mechanize.Mechanize
agent: org.smop.mechanize.Mechanize = org.smop.mechanize.Mechanize@612e3937
scala> agent.get("http://www.smop.org/")
res0: org.apache.http.HttpResponse = org.apache.http.message.BasicHttpResponse@3ab5b692
scala> agent.isSuccess
res1: Boolean = true
scala> agent.isHtml
@bartschuller
bartschuller / proto.js
Created January 12, 2011 12:41
Figuring out prototypes
var A, B, a, b, print, sys;
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor;
child.__super__ = parent.prototype;
return child;
};
sys = require('sys');
@bartschuller
bartschuller / proto.coffee
Created January 12, 2011 12:40
Figuring out prototypes
sys = require('sys')
print = sys.print
class A
bar: ->
print "A's bar\n"
this.baz()
baz: ->
@bartschuller
bartschuller / evaluator.js
Created January 3, 2011 21:14
Example of how to eval and then eval some more, adding to the scope of the first eval.
var evaluatorString =
'(function(stuff) {'+
' return eval("(function() {"'+
'+stuff+'+
'"return "+evaluatorString+";'+
'})();");'+
'})';
var scope1 = eval(evaluatorString);
var scope2 = scope1('var myVar = 42;');