Skip to content

Instantly share code, notes, and snippets.

View jashkenas's full-sized avatar

Jeremy Ashkenas jashkenas

View GitHub Profile
@jashkenas
jashkenas / wtf.coffee
Created August 25, 2011 19:12 — forked from gilesbowkett/wtf.coffee
why does this CoffeeScript not accurately translate this Ruby?
insert: (ball, column) ->
for row in @rows when row[column] is null
row[column] = ball
return
@jashkenas
jashkenas / searchhi
Created August 9, 2011 13:24
Trying CoffeeScript
highlightWord = (node, word) ->
if node.hasChildNodes
children = node.childNodes
highlightWord(item, word) for item in children
if node.nodeType == 3
tempNodeVal = node.nodeValue.toLowerCase()
tempWordValue = word.toLowerCase()
fs = require "fs"
path = require "path"
rimraf = require "rimraf"
{spawn} = require "child_process"
url = require "url"
heroku =
config: (callback) ->
child = spawn "heroku", ["config", "--shell"]
raw = ""
# In general, there are many places in the file where you can leave off the parens in function calls, if you like.
unless typeof exports is "undefined" # `unless ... else` reads poorly in English. Better to stick to `if ... else`.
Spine = exports
else
Spine = @Spine = {}
Spine.version = "0.0.4"
$ = Spine.$ = @jQuery || @Zepto || -> arguments[0] # In Coffee, `or` is preferred over `||`.
@jashkenas
jashkenas / gist:994057
Created May 26, 2011 20:53 — forked from steeleforge/gist:993924
SC 2.0a To-Do's coffee-script
Todos = SC.Application.create()
Todos.Todo = SC.Object.extend
title: null
isDone: false
Todos.todosController = SC.ArrayProxy.create
content: []
createTodo: (title) ->
York = {}
if exports?
_ = require 'underscore'
$ = require 'jquery'
Backbone = require 'backbone'
DNode = require 'dnode'
York = exports
server = true
else
json_data = JSON.stringify
"STATUS_ID is": status
"COMMAND is": command_str.trim()
"RESULT is": result_str
, null, '\n'
subdata = { }
for field in @updateable
subdata[ field ] = @data[ field ]
require.paths.unshift __dirname
express = require 'express'
app = express.createServer()
app.configure ->
app.set 'views', '#{__dirname}/views'
app.use express.logger()
app.use express.bodyDecoder()
options =
callback: => @interviewEditor.setup()
menuId: '#setup_interview'
$('#main_menu li#setup_interview a').bind 'click', options, @menuClickCallback