Skip to content

Instantly share code, notes, and snippets.

exports.HOST = process.argv[2] || '127.0.0.1';
exports.PORT = process.argv[3] || 11111;
@nkzawa
nkzawa / .travis.yml
Last active September 9, 2019 13:18
Testing mongoose models with mocha
language: node_js
node_js:
- 0.8
services:
- mongodb
@nkzawa
nkzawa / test_tojson.js
Created March 12, 2013 23:40
This test fails.
var assert = require('assert'),
mongoose = require('mongoose'),
Schema = mongoose.Schema,
connection;
beforeEach(function(done) {
connection = mongoose.createConnection('mongodb://localhost/test');
connection.on('open', function() {
connection.db.dropDatabase(done);
function vip() { vi $(find ${1:-.} -type f | peco); }
function killp() { ps aux | peco --query=${1} | awk '{print $2}' | xargs kill; }
it('should fire connect event on reconnect', function(done){
var socket = io({ forceNew: true });
var count = 0;
socket.on('connect', function() {
socket.on('myevent', function() {});
if (++count === 1) return;
expect(socket.listeners('myevent')).to.have.length(2);
socket.disconnect();
done();
});
var http = require('http');
var WebSocket = require('ws');
var bouncy = require('bouncy');
var wsServer = new WebSocket.Server({ noServer: true });
var httpServer = http.createServer();
httpServer.on('upgrade', function (req, socket, head) {
wsServer.handleUpgrade(req, socket, head, function(ws){
ws.on('message', function(message) {
block drop quick on en0 proto tcp from any to any port 9000
block drop quick on lo0 proto tcp from any to any port 9000
@nkzawa
nkzawa / .hyperterm.js
Created July 16, 2016 10:23
HyperTerm Solarized Dark colors based on https://gist.github.com/russelldavies/5745528
module.exports = {
config: {
// default font size for all tabs
fontSize: 12,
// font family with optional fallbacks
fontFamily: 'Menlo, "DejaVu Sans Mono", "Lucida Console", monospace',
// terminal cursor background color (hex)
cursorColor: '#839496',
@nkzawa
nkzawa / .hyperterm.js
Last active October 1, 2016 16:45
HyperTerm Solarized Dark colors based on https://gist.github.com/russelldavies/5745528
module.exports = {
config: {
// default font size for all tabs
fontSize: 12,
// font family with optional fallbacks
fontFamily: 'Menlo, "DejaVu Sans Mono", "Lucida Console", monospace',
// terminal cursor background color (hex)
cursorColor: '#839496',