Skip to content

Instantly share code, notes, and snippets.

View mcavage's full-sized avatar

Mark Cavage mcavage

View GitHub Profile
var bunyan = require('bunyan');
var restify = require('restify');
var server = restify.createServer({
log: bunyan.createLogger({
name: 'restify',
stream: process.stdout,
level: process.env.LOG_LEVEL || 'info',
serializers: restify.bunyan.serializers
})
@mcavage
mcavage / gist:3309350
Created August 10, 2012 00:08
telling me where to look further at what my restify app is doing...
putobject-ensureParent
value ------------- Distribution ------------- count
-1 | 0
0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 153
1 | 1
2 | 1
4 | 1
8 | 0
putobject-ensureContentLength
@mcavage
mcavage / gist:1856186
Created February 17, 2012 23:31
stopmachine.sh
#!/bin/bash
# Globals
#export SDC_CLI_URL=https://us-west-1.api.joyentcloud.com
#export SDC_CLI_ACCOUNT=mark.cavage
#export SDC_CLI_KEY_ID=id_rsa
var restify = require('restify');
///--- Globals
var NotAuthorizedError = restify.NotAuthorizedError;
/**
* Figure out how long it takes for a method to execute.
*
* @param {func} method to test
* @param {int} iterations number of executions.
* @param {Array} args to pass in.
* @param {T} context the context to call the method in.
* @return {int} the time it took, in milliseconds to execute.
*/
var bench = function (method, iterations, args, context) {
@mcavage
mcavage / gist:1712462
Created January 31, 2012 19:38
Argument checking simplification
if (!String.prototype.capitalize) {
String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
}
}
function assertArg(name, type) {
if (typeof(name) !== type)
throw new TypeError(name + '(' + type.capitalize() + ') required');
@mcavage
mcavage / gist:1563151
Created January 5, 2012 01:06
npmfreeze
#!/usr/bin/env node
// -*- mode: js -*-
var fs = require('fs');
var semver = require('semver');
var spawn = require('child_process').spawn;
///--- Globals
var deps = {};
[root@headnode (bh1-kvm1:0) ~]# plockstat -A -e 6 -p 40679
0
Mutex hold
Count nsec Lock Caller
-------------------------------------------------------------------------------
8421 1751 0xaa5408 beam.smp`erts_smp_mtx_unlock+0x9
2629 1749 0x61dee0 beam.smp`erts_deliver_time+0x4b
3257 1395 0xed46e8 beam.smp`erts_alcu_alloc_thr_pref+0xd6
208 21752 0xfffffd7fe97d9a70 beam.smp`do_port_command+0x34c
[root@headnode (bh1-kvm1:0) ~]# dtrace -n 'profile-997 /execname == "beam.smp"/ { @[stack()] = count(); }'
dtrace: description 'profile-997 ' matched 1 probe
^C
genunix`writev+0x248
unix`sys_syscall+0x17a
1
genunix`syscall_mstate+0x91
[root@headnode (coal:0) ~]# dtrace -n 'syscall:::entry /execname == "beam.smp"/ { self->s = timestamp; } syscall:::return /self->s/ { @[>
dtrace: description 'syscall:::entry ' matched 462 probes
^C
beam.smp mmap
value ------------- Distribution ------------- count
8192 | 0
16384 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2
32768 | 0