Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View jashkenas's full-sized avatar

Jeremy Ashkenas jashkenas

View GitHub Profile
View Constructor:
this.configure(options);
this._reset();
this.render();
Base View
.el - conventional root element reference for every view
.toElement - returns this.el
.childViews - Array of child views
#! /usr/bin/env ruby
require 'rubygems'
require 'hpricot'
username = "<username>"
password = "<password>"
tix = Hpricot(IO.popen("curl https://trac.zenbe.com/report/7 --basic -u #{username}:#{password} -k -s"))
(tix/"table.listing.tickets"/"tbody"/"tr").each do |row|
tcp: require 'tcp'
server: tcp.createServer (socket) ->
client: null
socket.addListener 'connect', ->
client: tcp.createConnection 22
client.addListener 'receive', (data) -> socket.send(data)
client.addListener 'eof', -> client.close()
Function.prototype.curry: (scope, rest...) ->
scope ||= this
=> @apply(scope, rest)
class B extends A
constructor: ->
@where_am_i: 'at work'
sayWhereYouAre: ->
alert 'I am ' + @where_am_i
function nodeFactory() {
function toStringFactory(data) { return function toString() {
// TODO: Implement
}}
function compileFactory(data) { return function compile() {
// TODO: Implement
}}
return {
BaseNode: function (data) {
return {
routes: {}
get: (route, handler) ->
routes[route]: handler
#############################################
get 'greet/:name', (request) ->
"Hello " + request.params['name']
func: (should_i) ->
do_it() if should_i = true
somevar: 0
while should_i = true
do_it()
somevar: somevar + 1
should_i: false
# Compared to
var __slice = function(array, from, to) {
return array.slice(
from < 0 ? from + array.length : from || 0,
to < 0 ? to + array.length : to == 0 ? to : array.length
);
};
# This Python:
@cache('public')
@get('/')
def hello():
return 'Hello World!'
# Can be done like this with CoffeeScript: