Skip to content

Instantly share code, notes, and snippets.

View ecto's full-sized avatar
🙂
building things

Cam Pedersen ecto

🙂
building things
View GitHub Profile
// function
// Constructor
// object { function, function }
var isomerize = function () {
if (arguments.length == 1) {
var code = arguments[0];
if (typeof code == 'function') {
return new LocalFunctionIsomer(code);
void setup () {
delay(1000);
Keyboard.begin();
// give the computer time to recognize a new keyboard
// this should be a bunch of escape presses though
delay(10000);
openProgram("terminal");
payload();
@ecto
ecto / keybase.md
Last active August 29, 2015 13:58

Keybase proof

I hereby claim:

  • I am ecto on github.
  • I am ecto (https://keybase.io/ecto) on keybase.
  • I have a public key whose fingerprint is C9A6 38A8 27EE F66E D42F 7A87 EC1B F1D8 EC90 E15A

To claim this, I am signing this object:

function Ticker () {
var ticks = 0;
this.tick = function () {
ticks++;
}
this.getTicks = funtion () {
return ticks;
}
@ecto
ecto / SKLabelButton.h
Created November 19, 2014 01:20
Quick SKLabelNode-based button for Sprite Kit
#import <SpriteKit/SpriteKit.h>
@interface SKLabelButton : SKLabelNode
@property (copy, nonatomic) void (^callback)();
@property (strong, nonatomic) UIColor *mainColor;
@property (strong, nonatomic) UIColor *highlightColor;
@property (nonatomic) bool touchWasCancelled;
+(instancetype)initWithCallback:(void (^)())callback;
@ecto
ecto / gist:59a9738ee7e5c1a81a02
Created April 7, 2015 14:42
Use of Weapons - Iain Banks
“Can’t machines build these faster?” he asked the woman, looking around the starship shell.
“Why, of course!” she laughed.
“Then why do you do it?”
“It’s fun. You see one of these big mothers sail out those doors for the first time, heading for deep space, three hundred people on board, everything working, the Mind quite happy, and you think; I helped build that. The fact a machine could have done it faster doesn’t alter the fact that it was you who actually did it.”
“Hmm,” he said.
app.get('/top', function(req, res){
db.keys('booking:*:name', function(err,keys){
if (err) { throw err; }
if (typeof(keys.forEach) == 'undefined') { res.redirect('/battle'); }
var bookings = [];
var originalCount = 0;
var returnCount = 0;
try { keys.forEach(function(key){
key = String(key);
var split = key.split(':');
TypeError: Object 394 has no method 'forEach'
at /home/ec2-user/jail/server.js:30:8
at Client.handleReply (/usr/local/lib/node/.npm/redis-node/0.2.7/package/lib/client.js:302:5)
at Client.<anonymous> (native)
at Client.emit (events:31:17)
at Client.handleData (/usr/local/lib/node/.npm/redis-node/0.2.7/package/lib/client.js:242:18)
at Stream.<anonymous> (native)
at Stream.emit (events:31:17)
at IOWatcher.callback (net:489:16)
at node.js:773:9
@ecto
ecto / elo.js
Created January 16, 2011 02:19
function adjust(ratings) {
ratings[0] = ratings[0] ? parseFloat(ratings[0]) : 1000;
ratings[1] = ratings[1] ? parseFloat(ratings[1]) : 1000;
var winnerExpected = 1 / (1 + (Math.pow(10,(ratings[1] - ratings[0]) / 400)));
var loserExpected = 1 / (1 + (Math.pow(10,(ratings[0] - ratings[1]) / 400)));
var k = 30;
var winnerAdjustment = Math.round(ratings[0] + (k * (1 - winnerExpected)));
var loserAdjustment = Math.round(ratings[1] + (k * (0 - loserExpected)));
return [winnerAdjustment, loserAdjustment];
}
@ecto
ecto / simple.js
Created January 24, 2011 18:13
ExpressJS app shell
var express = require('express'),
app = express.createServer();
app.get('/', function(req, res){
res.send('Hello World');
});
app.listen(3000);