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
#include <iostream> | |
#define ENUM_CLASS(Name, ...) \ | |
struct Name { \ | |
static int sCounter; \ | |
int mValue; \ | |
Name() : mValue(++Name::sCounter) {} \ | |
operator int() { return mValue; } \ | |
static Name __VA_ARGS__; \ | |
}; \ |
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 net = require('net'); | |
var os = require('os'); | |
function getLocalHosts() { | |
var hosts = ['0.0.0.0', '::']; | |
var interfaces = os.networkInterfaces(); | |
Object.keys(interfaces).forEach(function(interfaceName) { | |
var interface = interfaces[interfaceName]; | |
interface.forEach(function(info) { | |
var address = info.address; |
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
[ '0.0.0.0', | |
'::', | |
'::1', | |
'127.0.0.1', | |
'fe80::1%lo0', | |
'192.168.1.7' ] |
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 os = require('os'); | |
function getLocalHosts() { | |
var hosts = ['0.0.0.0', '::']; | |
var interfaces = os.networkInterfaces(); | |
Object.keys(interfaces).forEach(function(interfaceName) { | |
var interface = interfaces[interfaceName]; | |
interface.forEach(function(info) { | |
var address = info.address; | |
// append the interface name onto link-local IPv6 addresses |
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 net = require('net'); | |
function startServer(port, host, callback) { | |
var server = net.createServer(); | |
server.listen(port, host, function() { | |
callback(undefined, server); | |
}); | |
server.on('error', function(error) { | |
console.error('Ah damn!', error); | |
callback(error); |
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 net = require('net'); | |
var server = net.createServer(); | |
server.listen(4000, function() { | |
console.log('Listening on port 4000!'); | |
}); | |
server.on('error', function(error) { | |
console.error('Help!', error); | |
}); |
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
Using IPv4 unspecified address 0.0.0.0 | |
Using IPv6 unspecified address :: | |
Interface lo0 has address ::1 | |
Interface lo0 has address 127.0.0.1 | |
Interface lo0 has address fe80::1%lo0 | |
Interface en0 has address 192.168.1.7 | |
Starting too many servers on port 4567... | |
Listening on 0.0.0.0 port 4567 | |
Listening on :: port 4567 | |
Listening on ::1 port 4567 |
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 hash(str) { | |
var len = str.length; | |
var hash = 5381; | |
for (var idx = 0; idx < len; ++idx) { | |
hash = 33 * hash + str.charCodeAt(idx); | |
} | |
return hash; | |
} |
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 NOOP() {} | |
var button = getSomeButtonSomehow(); | |
// all of these Animation objects are immutable, and just describe the motion | |
var moveRight = Animate.positionX({ from: 0, to: 100, ease: Easing.easeOut, duration: 200 }); | |
var moveDown = Animate.positionY({ from: 0, to: 100, ease: Easing.easeOut, duration: 200 }); | |
var fadeOut = Animate.opacity({ to: 0, ease: Easing.cubicBezier(0,1,1,0), duration: 50 }); | |
var move = moveRight.with(moveDown, 100); // start moveDown 100ms after moveRight starts | |
var reusableAnimation = move.then(fadeOut, -fadeOut.duration); // start fadeOut 50ms before move ends |
NewerOlder