Skip to content

Instantly share code, notes, and snippets.

View dshaw's full-sized avatar
🦄
Always bet on Node.js ✨

Dan Shaw dshaw

🦄
Always bet on Node.js ✨
View GitHub Profile
@dshaw
dshaw / gist:1408474
Created November 30, 2011 09:05 — forked from shripadk/gist:1406702
#!/usr/bin/env node
var os = require('os');
var WebSocketClient = require('websocket').client;
var count = 0;
function recursion() {
var client = new WebSocketClient();
client.on('connectFailed', function(error) {
@dshaw
dshaw / starttls.js
Created November 17, 2011 16:29 — forked from TooTallNate/starttls.js
Upgrade a regular `net.Stream` connection to a secure `tls` connection.
// Target API:
//
// var s = require('net').createStream(25, 'smtp.example.com');
// s.on('connect', function() {
// require('starttls')(s, options, function() {
// if (!s.authorized) {
// s.destroy();
// return;
// }
//
@dshaw
dshaw / fp.js
Created October 16, 2011 04:17
fp.js snippets
// @littlecalculist
var bind = Function.prototype.call.bind(Function.prototype.bind)
var call = bind(Function.prototype.call, Function.prototype.call)
var apply = bind(Function.prototype.call, Function.prototype.apply)
// @cowboy
var typeorama = Function.prototype.call.bind(Object.prototype.toString)
// @dshaw
var toString = Function.prototype.call.bind(Object.prototype.toString)
@dshaw
dshaw / HelloDartTest.dart
Created October 12, 2011 00:27
Dart Compilation
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Simple test program invoked with an option to eagerly
// compile all code that is loaded in the isolate.
// VMOptions=--compile_all
class HelloDartTest {
static testMain() {
print("Hello, Darter!");
@dshaw
dshaw / Procfile
Created October 6, 2011 19:05 — forked from getify/browser-net-output.txt
trouble getting socket.io to work in node
web: node server.js
# From yorick on IRC.
$ npm outdated
var npm = require('/usr/local/lib/node_modules/npm/npm.js');
npm.load({}, function(er) { if (er) handle_error(er); npm.commands.outdated(function(er, data) { ... }) })
npm.commands.install
@dshaw
dshaw / index.html
Created September 21, 2011 21:05 — forked from 3rd-Eden/index.html
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<form id="chat">
<fieldset id="blabla">
</fieldset>
@dshaw
dshaw / gist:1212938
Created September 13, 2011 01:33 — forked from antirez/gist:1211737
How to add cmd-left-arrow and cmd-right-arrow (without shift) key bindings to the mac os x Terminal
app if the Lion install removed this bindings from your system.
1) Open "System Preferences".
2) Go to "Keyboard".
3) Select the "Keyboard Shortcuts" tab.
4) Select "Application Shortcuts" from the list of items in the left.
5) Press "+" to add a new shurtcut.
6) As "Application" select "Terminal", as "Menu Title" use: "Select Next Tab". For the "Keyboard Shortcut" field just select the field and press cmd-right-arrow.
7) Repeat again from step 5, using "Select Previous Tab" as Menu Title and pressing cmd-left-arrow as keyboard shortcut.
http_simple (/bytes/1024) over 1-gbit network, with 700 concurrent connections:
------------------------------------------------------------------------------
windows-0.5.4 : 3869 r/s
windows-latest : 4990 r/s
linux-latest-legacy : 5215 r/s
linux-latest-uv : 4970 r/s
@dshaw
dshaw / gist:1145696
Created August 15, 2011 04:01 — forked from devongovett/gist:1037265
jsondb + msgpack
var arr = [],
obj = {'abcdef' : 1, 'qqq' : 13, '19' : [1, 2, 3, 4]};
for(var i = 0; i < 5000; i++)
arr.push(obj);
// jsondb(arr) looks something like this:
// ["abcdef", "qqq", "19", [1, 13, [1, 2, 3, 4]], [1, 13, [1, 2, 3, 4]]...]
> JSON.stringify(arr).length //original