Skip to content

Instantly share code, notes, and snippets.

Avatar

Jeremy Ashkenas jashkenas

View GitHub Profile
@jashkenas
jashkenas / wtf.coffee
Created Aug 25, 2011 — forked from gilesbowkett/wtf.coffee
why does this CoffeeScript not accurately translate this Ruby?
View wtf.coffee
insert: (ball, column) ->
for row in @rows when row[column] is null
row[column] = ball
return
@jashkenas
jashkenas / searchhi
Created Aug 9, 2011
Trying CoffeeScript
View searchhi
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()
View Cakefile
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 = ""
View spine.coffee
# 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 — forked from steeleforge/gist:993924
SC 2.0a To-Do's coffee-script
View gist:994057
Todos = SC.Application.create()
Todos.Todo = SC.Object.extend
title: null
isDone: false
Todos.todosController = SC.ArrayProxy.create
content: []
createTodo: (title) ->
View x.coffee
York = {}
if exports?
_ = require 'underscore'
$ = require 'jquery'
Backbone = require 'backbone'
DNode = require 'dnode'
York = exports
server = true
else
View json.coffee
json_data = JSON.stringify
"STATUS_ID is": status
"COMMAND is": command_str.trim()
"RESULT is": result_str
, null, '\n'
View gist:806647
subdata = { }
for field in @updateable
subdata[ field ] = @data[ field ]
View index.coffee
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()
View messy_syntax.coffee
options =
callback: => @interviewEditor.setup()
menuId: '#setup_interview'
$('#main_menu li#setup_interview a').bind 'click', options, @menuClickCallback