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
var Laws = { | |
drinking_age : function (fn) { | |
fn(this.age > 21); | |
} | |
} | |
/* snip */ | |
Laws.drinking_age.call(this, function (able_to_drink) { |
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
var Laws = { | |
drinking_age : function (age, fn) { | |
fn(age > 21); | |
} | |
} | |
Student.prototype.check_drinking = function check_drinking (fn) { | |
Laws.drinking_age(this.age, function (able_to_drink) { | |
if (able_to_drink) { | |
fn(null, true); |
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
function Student (name, age) { | |
this.name = name; | |
this.age = age; | |
} | |
Student.prototype.toString = function toString () { | |
return this.name + " is " + this.age + " years old."; | |
}; | |
var me = new Student("Joshua", 26); |
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 class Student | |
{ | |
String name; | |
int age; | |
public Student (String name, int age) | |
{ | |
this.name = name; | |
this.age = age; | |
} |
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 SocketServer | |
import SimpleHTTPServer | |
PORT = 1339 | |
def fibonacci (n): | |
if n < 2: | |
return 1 | |
else: | |
return fibonacci(n - 2) + fibonacci(n - 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
Joshs-MacBook-Pro:~ josh$ ab -n 10 -c 5 http://127.0.0.1:1337/ | |
This is ApacheBench, Version 2.3 <$Revision: 655654 $> | |
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ | |
Licensed to The Apache Software Foundation, http://www.apache.org/ | |
Benchmarking 127.0.0.1 (be patient).....done | |
Server Software: | |
Server Hostname: 127.0.0.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
var http = require('http'); | |
function fibonacci(n) { | |
if (n < 2) | |
return 1; | |
else | |
return fibonacci(n-2) + fibonacci(n-1); | |
} | |
http.createServer(function (req, res) { |
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
Number is: <?php | |
function fibonacci($n) { | |
if ($n < 2) { | |
return 1; | |
} else { | |
return fibonacci($n - 2) + fibonacci($n - 1); | |
} | |
} | |
echo fibonacci(40); | |
?> |
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
// Date library | |
var log4js = require('log4js'), | |
log = log4js.getLogger('Date'), | |
fmts = { | |
// Returns the full day of the week (e.g. Sunday) | |
'A' : function (d) { | |
var day = d.getUTCDay(); | |
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
> db.users.findOne | |
function (query, fields) { | |
var cursor = this._mongo.find(this._fullName, this._massageObject(query) || {}, fields, -1, 0, 0, 0); | |
if (!cursor.hasNext()) { | |
return null; | |
} | |
var ret = cursor.next(); | |
if (cursor.hasNext()) { | |
throw "findOne has more than 1 result!"; | |
} |