Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@trentm
trentm / ben-arrayiter.js
Last active April 12, 2016 16:51
Slow JavaScript array iter
var ben = require('ben');
var servers = [];
for (var i = 0; i < 1000; i++) {
servers.push({"uuid": "blah", "hostname": "blah", "vms": {"foo": "blah"}});
}
var forMs = ben(function () {
var filteredServers = [];
for (var i = 0; i < servers.length; i++) {
root@blackduck0:~/tmp/q# ls */package.json | grep -v sdc-headnode | grep -v sdc-amon | cut -d/ -f1
aperture-config
binder
cloud-tycoon
electric-moray
eng
keyapi
mahi
manatee
manta-mackerel
@trentm
trentm / output.txt
Created February 23, 2016 19:47
hack to node-tape to get timestamps on TAP test results
ok 41 [2016-02-23T19:45:28.419Z] createMachine
ok 42 [2016-02-23T19:45:28.419Z] createMachine 201 statusCode
ok 43 [2016-02-23T19:45:28.419Z] createMachine Location header
ok 44 [2016-02-23T19:45:28.419Z] createMachine body: 7d609b77-7821-459d-894f-637f9d5a3e05
ok 45 [2016-02-23T19:45:28.420Z] headers ok
ok 46 [2016-02-23T19:45:28.420Z] headers allow-origin
ok 47 [2016-02-23T19:45:28.420Z] headers allow-methods
ok 48 [2016-02-23T19:45:28.421Z] headers date
ok 49 [2016-02-23T19:45:28.421Z] headers request-id
ok 50 [2016-02-23T19:45:28.422Z] headers response time
---
hr:
- Mark McGwire
# Following node labeled SS
- &SS Sammy Sosa
rbi:
- *SS # Subsequent occurrence
- Ken Griffey
@trentm
trentm / manual-sdcadm-self-update.sh
Created November 6, 2015 18:11
manual install of latest sdcadm (for https://joyent.com/triton)
updates-imgadm get-file -o latest-sdcadm.sh $(updates-imgadm list name=sdcadm --latest -H -o uuid)
bash latest-sdcadm.sh
[root@d632a4c8-2a8d-44bd-842d-f898fe95271c ~/src/node]# uname -a
SunOS d632a4c8-2a8d-44bd-842d-f898fe95271c.local 5.11 joyent_20120424T232010Z i86pc i386 i86pc Solaris
[root@d632a4c8-2a8d-44bd-842d-f898fe95271c ~/src/node]# gcc --version
gcc (GCC) 4.7.0
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[root@d632a4c8-2a8d-44bd-842d-f898fe95271c ~/src/node]# git log -1
commit 771ba34ca7b839add2ef96879e1ffc684813cf7c
Index: /Users/trentm/tm/json/lib/jsontool.js
index 734729c..d2764f9 100755
--- a/lib/jsontool.js
+++ b/lib/jsontool.js
@@ -399,36 +399,140 @@ function parseArgv(argv) {
* Get input from either given file paths or stdin.
*
* @param opts {Object} Parsed options.
- * @param callback {Function} `function (err, callback)` where err is an
- * error string if there was a problem.
[root@headnode (bh1-kvm7:0)]# cat foo.js
var fs = require('fs');
fs.watch("/var/tmp/follow.log", {persistent: true}, function (event, filename) {
console.log("EVENT", event, filename);
});
[root@headnode (bh1-kvm7:0)]# ./build/node/bin/node --version
v0.6.19
[root@headnode (bh1-kvm7:0)]# uname -a
SunOS headnode 5.11 joyent_20120723T091636Z i86pc i386 i86pc
@trentm
trentm / fetch.diff
Created June 28, 2012 19:36
better fetch
Index: /Users/trentm/tm/npm/lib/utils/fetch.js
index b489c21..6042abc 100644
--- a/lib/utils/fetch.js
+++ b/lib/utils/fetch.js
@@ -25,17 +25,31 @@ function fetch (remote, local, headers, cb) {
function fetch_ (remote, local, headers, cb) {
var fstr = fs.createWriteStream(local, { mode : npm.modes.file })
+ var response = null
+ var calledback = false
@trentm
trentm / no-retry-on-404.log
Created June 28, 2012 19:23
npm retry on 408 or 5xx only: npm/lib/cache.js and fetch.js changes
$ touch proxy.js && sleep 1 && rm -rf tmp/cache node_modules/bunyan && node ~/tm/npm/cli.js --loglevel=info --cache=`pwd`/tmp/cache --registry=http://localhost:8000/ install bunyan@0.6.8npm info it worked if it ends with ok
npm info using npm@1.1.32
npm info using node@v0.6.19
npm info retry registry request attempt 1 at 12:21:47
npm http GET http://localhost:8000/bunyan/0.6.8
npm http 200 http://localhost:8000/bunyan/0.6.8
npm info retry fetch attempt 1 at 12:21:48
npm http GET http://localhost:8000/bunyan/-/bunyan-0.6.8-BOGUS.tgz
npm http 404 http://localhost:8000/bunyan/-/bunyan-0.6.8-BOGUS.tgz
npm ERR! fetch failed http://localhost:8000/bunyan/-/bunyan-0.6.8-BOGUS.tgz