Skip to content

Instantly share code, notes, and snippets.

View samfrons's full-sized avatar

Sam Frons samfrons

  • Brooklyn, NY
View GitHub Profile
@samfrons
samfrons / main.js
Last active December 29, 2015 23:19
Choose your own adventure in javascript
var attacker = prompt("What\'s the easiest assailant to fend off- a NARWHAL with a cane, a SHRUB with gun, or a MONK in a funk? ").toUpperCase();
switch(attacker) {
case 'NARWHAL':
var strong = prompt("How courageous! Are you strong (YES or NO)?").toUpperCase();
var smart = prompt("Are you smart?").toUpperCase();
if(strong === 'YES' || smart === 'YES') {
console.log("You only need one of the two! You beat the troll--nice work!");
} else {
console.log("You're not strong OR smart? Well, if you were smarter, you probably wouldn't have tried to fight a troll. You lose!");
}
@samfrons
samfrons / chat.js
Created June 29, 2011 02:41
chat server in node.js
net = require('net')
Array.prototype.remove = (element) ->
for e, i in this when e is element
return this.splice(i, 1)
class Client
constructor: (stream) ->
@stream = stream
@name = null
var http = require("http");
sys = require('sys');
var server = http.createServer(function(request,response) {
request.addListener('end' , function () {
response.writeHead(200, {
"Content-Type": "text/plain"
});
response.write(sys.inspect(request));