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++) {
@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

Issues with nodejs.org binaries for SmartOS users

Description of the problem

Node v4.x.y binaries have been built with compilers at versions greater than the ones used to build packages in the LTS pkgsrc repositories. They've been built with gcc 4.9 and gcc 4.8, when the compiler used to build packages from the 2014Q4 pkgsrc repository is gcc 4.7.3.

As a consequence, these node v4.x.y binaries downloaded from nodejs.org have

@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
@trentm
trentm / magic.js
Created March 24, 2015 02:35
compressed file type detection using magic numbers. Wrote it. Don't need it right now.
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at http://smartos.org/CDDL
*
@glennblock
glennblock / fork forced sync
Created March 4, 2012 19:27
Force your forked repo to be the same as upstream.
git fetch upstream
git reset --hard upstream/master
#!/bin/bash
SERVER=https://api.no.de
SCRIPT="$0"
if [ ${SCRIPT:0:1} == "/" ]; then
SCRIPT="$(basename -- "$SCRIPT")"
fi
main () {
cmd=${1-help}
var stdin = process.stdin
, stdio = process.binding("stdio")
stdio.setRawMode()
// let the data flow.
// stdin is "paused" initially.
stdin.resume()
var password = ""
stdin.on("data", function (c) {
# Makefile
#...