This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Product = Backbone.Model.extend({ | |
fromStoreName: function() { return 'Crate & Barrel'; } | |
}); | |
var glassJar = new Product({ storesUrl: 'http://www.crateandbarrel.com' }); | |
var products = new Backbone.Collection; | |
products.add([glassJar]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@sendNameChange($('#username').attr 'value' ) unless | |
$("#username").css('display') is 'none' and | |
$("#username").attr("value").search("user") is -1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Working JS | |
var server = Connect.createServer( | |
Connect.logger(), | |
Connect.staticProvider(__dirname + '/public'), | |
function(req, res) { | |
res.writeHead(200, { 'Content-Type': 'text/plain' }); | |
res.write('Hello World'); | |
res.end(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app = require('express').createServer() | |
md = require('node-markdown').Markdown | |
app.get '/', (req, res) -> | |
res.send md "Hello, *world*! The time is\n\n**#{ new Date() }**" | |
app.listen 3000 | |
console.log 'Now listening on port 3000' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
write = (buffer, offset, length) -> | |
offset or= 0 | |
length or= buffer.length | |
while machine and offset < length | |
pattern = machine.definition.pattern[machine.index] | |
if pattern.arrayed | |
loop | |
buffer[offset] = machine.value[machine.offset] | |
machine.offset += machine.increment | |
bytesWritten++ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
write = (buffer) -> | |
offset = if arguments.length > 1 then arguments[1] else 0 | |
length = if arguments.length > 2 then arguments[2] else buffer.length | |
done = false | |
while not done and machine isnt null and offset < length | |
pattern = machine.definition.pattern[machine.index] | |
if pattern.arrayed | |
loop | |
buffer[offset] = machine.value[machine.offset] | |
machine.offset += machine.increment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Planet | |
constructor: (@name, @size, @x, @y) -> | |
@ships = {} | |
battle: -> | |
for p of @ships | |
damage = randint @ships[p] | |
add_ships: (player, amount) -> | |
if @ships[player]? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
switch(protocol) { | |
//first set it to secure | |
case "https:": | |
stream.setSecure(true) | |
case "http:": | |
stream.write(text) | |
stream.end() | |
break | |
case "ftp:": | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |