Skip to content

Instantly share code, notes, and snippets.

View tim-smart's full-sized avatar

Tim tim-smart

View GitHub Profile
var A = function() {};
A.prototype.over = function() {};
var B = function() {
this.where_am_i = 'at work';
A.call(this);
};
var _fn = function() {};
class Base
constructor: (type) ->
@type: type
class Tower extends Base
constructor: (material) ->
super 'tower'
@material: material
function test(arg, arg2) {};
// This
test.apply(test, [1, 2]);
// Is the same as
test.call(test, 1, 2);
hookIO.addListener('JsonrpcRequest', function(request, response) {
try {
var requestData = JSON.parse(request.body);
hookIO.emit('JsonrpcResponse', response,
hookIO.api[requestData.method].apply(hookIO.api, requestData.params));
} catch (error) {
hookIO.emit('Jsonrpc404Response', response, error);
}
});
# A class literal, including optional superclass and constructor.
exports.ClassNode: class ClassNode extends BaseNode
type: 'Class'
constructor: (variable, parent, props) ->
@children: compact flatten [@variable: variable, @parent: parent, @properties: props or []]
compile_node: (o) ->
extension: @parent and new ExtendsNode(@variable, @parent)
constructor: null
http: require 'http'
body: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"' +
' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' +
'<html>' +
' <head>' +
' <meta http-equiv="Content-type" content="text/html; charset=utf-8" />' +
' <title>Page Title</title>' +
' <script type="text/javascript" charset="utf-8">' +
' document.addEventListener("DOMContentLoaded", function(ev) {' +
http: require 'http'
body: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"' +
' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' +
'<html>' +
' <head>' +
' <meta http-equiv="Content-type" content="text/html; charset=utf-8" />' +
' <title>Page Title</title>' +
' </head>' +
' <body>' +
Connection.prototype.query = function (sql, callback) {
if (!this._queries) this._queries = [];
this._queries.push([sql, callback]);
this.maybeDispatchQuery();
};
var fs, path;
fs = require('fs');
path = require('path');
process.mixin(global, require('sys'));
exports.directoryWalker = function directoryWalker(dir, callback, maxLevels, currentLevel, fromRoot) {
maxLevels = 'number' === typeof maxLevels ? maxLevels : 0;
currentLevel = 'number' === typeof currentLevel ? currentLevel : 1;
fromRoot = 'string' === typeof fromRoot ? fromRoot : '';
return fs.readdir(dir, function(error, files) {
if (error) {
var Animal = (function () {
var youCantSeeMe = 123;
return function () {
this.butIcan = 2 * youCantSeeMe;
};
})();
Animal.prototype.test = function() {
return this.butIcan;
};