Skip to content

Instantly share code, notes, and snippets.

View jwerle's full-sized avatar
🔨
Working on @socketsupply/socket

Joseph Werle jwerle

🔨
Working on @socketsupply/socket
View GitHub Profile
werle:~/repos/libuv-http ☀ master
√ make
git clone --depth 1 https://chromium.googlesource.com/external/gyp.git ./deps/gyp
Cloning into './deps/gyp'...
remote: Counting objects: 1631, done
remote: Finding sources: 100% (1631/1631)
remote: Total 1631 (delta 332), reused 980 (delta 332)
Receiving objects: 100% (1631/1631), 813.68 KiB | 0 bytes/s, done.
Resolving deltas: 100% (332/332), done.
Checking connectivity... done.
@jwerle
jwerle / output
Created September 2, 2014 22:34
leaks in setenv - OSX
werle:~/tmp
× cc setenvbug.c -o setenvbug
werle:~/tmp
√ valgrind --leak-check=yes --track-origins=yes --dsymutil=yes setenvbug
==37306== Memcheck, a memory error detector
==37306== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==37306== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==37306== Command: setenvbug
==37306==
var queue = [];
function enqueue (work) {
queue.push(work);
}
function dequeue () {
for (var i = 0; i < queue.length; ++i) void function (work, i) {
work(
function (isDone) {
var m = {exports: {}};
(function (module, exports, require) {
console.log(module, exports, require('./foo.js'));
})(m, m.exports, function (name) { return Function(String(fs.readFileSync(name)))(); });
@jwerle
jwerle / matrix-identity-from-kronecker.js
Created September 16, 2015 18:17
Identity matrix construction from the KroneckerDelta function
'use strict';
// kronecker delta
let kd = (i, j) => i == j ? 1 : 0;
// (In)ij identity matrix constructor
let I = n => {
let a = [], k = 0;
for (let i = 0; i < n; ++i)
for (let j = 0; j < n; ++j)
a[k++] = kd(i, j);
@jwerle
jwerle / gfsn.js
Created November 27, 2012 20:53
Get Satisfaction quick implementation
/*
* The Daily Voice
* Copyright 2012 Daily Voice (www.DailyVoice.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@jwerle
jwerle / foo.new.js
Created January 5, 2013 21:48
.new method like Ruby for Javascript
/**
* With some magic getters/setters you can achieve similar syntax like Ruby
**/
function foo() { console.log('im foo') }
foo.__defineGetter__('new', function(){ return new foo })
f = foo.new
// >> im foo
void console.log((new foo) instanceof foo)
// >> im foo
@jwerle
jwerle / basic-simulation-node-module.js
Last active December 14, 2015 07:39
Basic simulation of a Node module
function Module(scope, global){
this.scope = scope;
this.exports = {};
this.global = global || window || this;
}
function ModuleError(message) {
Error.call(this);
Error.captureStackTrace(this, ModuleError);
this.name = 'ModuleError';
@jwerle
jwerle / overload-emit.js
Created May 14, 2013 20:36
overload .emit()
var http, server, emit
http = require('http')
server = http.createServer(function () { console.log('ok') })
emit = emit = server.emit
server.emit = function () {
// log it out
console.log('[server]:', arguments[0])
// apply old emit
emit.apply(this, arguments);
};
var mongoose = require('mongoose'),
Config = mongoose.model('Config')
exports.create = function(req, res) {
var conf = new Config(req.body);
console.log(conf)
conf.save(function(err) {