Skip to content

Instantly share code, notes, and snippets.

View jashkenas's full-sized avatar

Jeremy Ashkenas jashkenas

View GitHub Profile
if process?
Obj: exports
Hash: require './hash'
else
Obj: window.Obj: {}
Hash: window.Hash: {}
if process?
Obj: exports
Hash: require './hash'
else
window.Obj: {}
window.Hash: {}
when World.Surface.CANVAS.FORE
g: context.createRadialGradient 0, 0, 0, 0, 0, 50
g.addColorStop 0.4, "rgba(150, 183, 51, 1)"
g.addColorStop 0.9, "rgba(150, 183, 51, 0)"
context.fillStyle: g2
context.beginPath()
context.arc 0, 0, 45, 0, Math.PI*2, true
context.closePath()
context.fill()
$(document).ready ->
gSmallShadow: new google.maps.MarkerImage("http://labs.google.com/ridefinder/images/mm_20_shadow.png", new google.maps.Size(22, 20), new google.maps.Point(0, 0), new google.maps.Point(6, 20))
gYellowIcon: new google.maps.MarkerImage("http://labs.google.com/ridefinder/images/mm_20_yellow.png", new google.maps.Size(12, 20), new google.maps.Point(0, 0), new google.maps.Point(6, 20))
places: {}
updatePlaces: ->
bounds: map.getBounds()
ne: bounds.getNorthEast()
sw: bounds.getSouthWest()
$.ajax({
class Base
someMethod: ->
puts "hello from Base"
class Derived extends Base
someOtherMethod: ->
@someMethod()
x: new Derived()
x.someOtherMethod()
attributes_value: self.template_eval "\$H($attributes_hash)"
# This Python:
@cache('public')
@get('/')
def hello():
return 'Hello World!'
# Can be done like this with CoffeeScript:
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
);
};
routes: {}
get: (route, handler) ->
routes[route]: handler
#############################################
get 'greet/:name', (request) ->
"Hello " + request.params['name']