Skip to content

Instantly share code, notes, and snippets.

View jashkenas's full-sized avatar

Jeremy Ashkenas jashkenas

View GitHub Profile
; Ranking
; Votes divided by the age in hours to the gravityth power.
; Would be interesting to scale gravity in a slider.
(= gravity* 1.8 timebase* 120 front-threshold* 1
nourl-factor* .4 lightweight-factor* .3 )
(def frontpage-rank (s (o scorefn realscore) (o gravity gravity*))
(* (/ (let base (- (scorefn s) 1)
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 = ""
<div class="singleAd" id="TopLeft">
<SCRIPT LANGUAGE= "JavaScript">
var CM8Server= "gucci.checkm8.com";
var CM8Cat="gucci.nyt";
var CM8Profile="&format=Bookend left";
var CM8Req="x";
var CM8Redir={click: "", ad_play: ""};
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="http://guccidigital.checkm8.com/adam/cm8_detect_ad.js">
</SCRIPT>
apply = if Prototype.Browser.IE
(o, a) ->
a or= []
switch a.length
when 0 then return @call o
when 1 then return @call o, a[0]# shreddin' the argument powder
when 2 then return @call o, a[0], a[1]# \__O_/
when 3 then return @call o, a[0], a[1], a[2]# |
when 4 then return @call o, a[0], a[1], a[2], a[3]# \ /\
when 5 then return @call o, a[0], a[1], a[2], a[3], a[4]# \ /
# Class literals.
class Doctor
diagnose: ->
console.log "You have died of dysentery."
class LyingDoctor extends Doctor
diagnose: ->
console.log "You have died of old age."
# 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) ->
~ > cat /usr/local/bin/git-publish
#!/usr/bin/env ruby
cmds = []
cmds << "git co gh-pages"
cmds << "git merge master"
cmds << "git push github gh-pages"
cmds << "git co master"
system cmds.join("&&")
# Try to load the compressors, if available.
compressor_map = {
:closure => 'closure-compiler',
:yui => 'yui/compressor',
:uglifier => 'uglifier',
:sass => 'sass'
}
compressor_map.each do |compressor, library|
begin
for i in [-1..1]
for j in [-1..1]
if @isAlive cell.row + i, cell.col + j
neighbors++