Some exercises from the Falsy Values workshops.
The good parts:
- HTTP server and client in same script
- Express cookies example
- Express routing example
- Express error handling
- Express middlewares example
- Simple HTTP proxy
require 'dalton/strategies/skroutz' | |
require 'dalton/strategies/facebook' | |
require 'dalton/strategies/openid' # yahoo, #google | |
require 'dalton/strategies/twitter' | |
# Setup OpenId file storage, don't change the storage engine! | |
require 'openid/store/filesystem' | |
Rails.configuration.middleware.use(Rack::OpenID, | |
OpenID::Store::Filesystem.new(Rails.root + 'tmp/openid')) |
// helper function that goes inside your socket connection | |
client.connectSession = function(fn) { | |
var cookie = client.request.headers.cookie; | |
var sid = unescape(cookie.match(/connect\.sid=([^;]+)/)[1]); | |
redis.get(sid, function(err, data) { | |
fn(err, JSON.parse(data)); | |
}); | |
}; | |
// usage |
require.registerExtension('.js', function(js){ | |
return js.replace(/^ *\/\/debug: */gm, ''); | |
}); |
/* | |
A simple new-line delimited JSON protocol with upgrades. | |
Receiving Usage: | |
protocol = require('./frame-protocol'); | |
// parsing data | |
parser = protocol.Parser(); |
Some exercises from the Falsy Values workshops.
The good parts:
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
A list of Sketch plugins hosted at GitHub, in no particular order.
#!/usr/bin/python | |
import json | |
import sys | |
import os | |
import datetime | |
import codecs | |
import sqlite3 | |
import re | |
import struct |
After publishing my article on ECMAScript 6, some have reached out to ask how I exactly I make it all work.
I refrained from including these details on the original post because they're subject to immiment obsoletion. These tools are changing and evolving quickly, and some of these instructions are likely to become outdated in the coming months or even weeks.
When evaluating the available transpilers, I decided to use 6to5, which has recently been renamed to Babel. I chose it based on: