Skip to content

Instantly share code, notes, and snippets.

View jashkenas's full-sized avatar

Jeremy Ashkenas jashkenas

View GitHub Profile
attributes_value: self.template_eval "\$H($attributes_hash)"
class Base
someMethod: ->
puts "hello from Base"
class Derived extends Base
someOtherMethod: ->
@someMethod()
x: new Derived()
x.someOtherMethod()
$(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({
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()
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: {}
# sample use: node nodeproxy.js 127.0.0.1 88 127.0.0.1 80
net: require 'net'
sys: require 'sys'
[proxyHost, proxyPort, proxyTargetHost, proxyTargetPort]: process.argv.slice(2)
proxyServer: net.createServer (source_stream) ->
source_stream.addListener 'connect', ->
target_stream: new net.Stream()
target_stream.addListener 'connect', -> sys.pump source_stream, target_stream
switch(protocol) {
//first set it to secure
case "https:":
stream.setSecure(true)
case "http:":
stream.write(text)
stream.end()
break
case "ftp:":
...
class Planet
constructor: (@name, @size, @x, @y) ->
@ships = {}
battle: ->
for p of @ships
damage = randint @ships[p]
add_ships: (player, amount) ->
if @ships[player]?
function Client() {
this.state = "loggedoff"
}
//attempt to say something, will attempt login every time and keep you at as far as you have gotten
Client.prototype.say = function(msg) {
switch(this.state) {
case "loggedoff":
this.queueLogin()
case "authenticated":