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
# serving of squash | |
from bottle import route, run, send_file, abort, request, response, redirect, template | |
from squash import * | |
from settings import * | |
# Squash homepage, with form for generating short urls | |
@route('/') | |
def homepage(): | |
return template('squashit.tpl',title='Shorten your URLs with Squash!') |
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 'watir' | |
browser = gets.strip | |
if browser == 'safari' or browser == 'firefox' | |
Watir::Browser.default = browser | |
b = Watir::Browser.new | |
b.goto "http://localhost:8000/" | |
sleep 5.0 | |
at_homepage = b.link(:text, "Login").exists? |
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 somecoolfablibrary | |
robot = somecoolfablibrary.Robot() | |
robot.dice_bread(two_loaves) | |
robot.flavor_bread(butter, herbs) | |
robot.bake_bread() |
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
// set your configurations | |
var server = 'irc.freenode.net' | |
var channels = ['#kennyshen'] | |
var nick = 'tocho-san' | |
var password = '' | |
var auth = false; // if no password, not registered, set to false. | |
var logmode = 'nstore' // nstore or text | |
var logfile = 'log.db' | |
// exports |
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
// Or insert with auto key | |
users.save(null, {name: "Bob"}, function (err, meta) { | |
if (err) { throw err; } | |
// You now have the insert id | |
}); |
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
// basic imports | |
var sys = require('sys'); | |
var events = require('events'); | |
// for us to do a require later | |
exports.Dummy = Dummy; | |
function Dummy() { | |
var self = this; | |
events.EventEmitter.call(self); |
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
Dummy.prototype.cooking = function(chicken) { | |
var self = this; | |
self.chicken = chicken; | |
self.cook = cook(); // assume dummy function that'll do the cooking | |
self.cook(chicken, function(cooked_chicken) { | |
self.chicken = cooked_chicken; | |
self.emit('cooked', self.chicken); | |
}); | |
return self; |
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 nonsensical node.js program | |
var dummy = require('./dummy'); | |
var kenny = new dummy.Dummy(); | |
var dinner = kenny.cooking(fried_chix); | |
dinner.on('cooked', function(chicken) { | |
// eat up! | |
} |
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
class Student(): | |
def __init__(self): | |
self.grade = '' | |
self.name = '' | |
self.sclass = '' | |
self.form_teacher = '' | |
def register(self, name): | |
self.name = name |
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 Student = { | |
chat: function() { | |
return "hello i'm " + this.name + " from " + this.sclass + " and my teacher is " + this.form_teacher + "."; | |
} | |
} | |
var kenny = Object.create(Student); | |
kenny.name = "kenny"; | |
kenny.sclass = "4B"; | |
kenny.form_teacher = "Mr Sim"; |