Skip to content

Instantly share code, notes, and snippets.

@metamatt
metamatt / fast wake
Created October 28, 2014 17:01
This is my new mandatory sequence after upgrading OS X, since I prioritize my laptop waking up the second I open it higher than month-long standby, and this is apparently contrary to Apple's priorities since every OS X upgrade seems to nerf my settings back to the defaults: http://blog.metamatt.com/blog/2013/03/20/apple-is-getting-really-aggress…
magi@duality ~> sudo pmset -b standbydelay 43200
magi@duality ~> sudo pmset -c standby 0
magi@duality ~> pmset -g
Active Profiles:
Battery Power -1*
AC Power -1
Currently in use:
standbydelay 43200
standby 1
halfdim 1
@metamatt
metamatt / fiberStacks.js
Last active August 29, 2015 14:07
Demo of the call stacks you get from console.trace for a few scenarios involving node-fibers.
'use strict';
var Fiber = require('fibers');
var Future = require('fibers/future');
function test() {
console.trace('trace from root non-fiber');
// Create fiber explicitly, the low-level way.
var f1 = Fiber(function fiber1() {
@metamatt
metamatt / preemption.js
Created October 10, 2014 08:35
Demo of undesirable preemption in NodeJS due to MakeCallback.
//
// preemption.js
//
// Demo of undesirable preemption in NodeJS 0.10 (at least) due to MakeCallback;
// outer JS code that's running along happily but transitions to C++ code and then
// some inner JS code and back can find that state has changed out from under it,
// in ways it cannot predict (or conversely, that the inner JS code can observe
// shared data structures in an inconsistent state because the outer code was in
// the process of making changes to them that were intended to be atomic, and are
// not atomic due to this preemption).
@metamatt
metamatt / gist:e654f8ce7e25ed0fc906
Last active August 29, 2015 14:06
url.parse api changes between node 0.10 and node 0.12 break karma
See for example https://github.com/karma-runner/karma/blob/master/lib/middleware/karma.js#L40, which assumes the result of `url.parse(foo, true)` always has a non-null `.query` property.
In node 0.10.26:
magi@ubuntu ~/s/d/experiments> node-0.10.26
> url.parse('/foo', true)
{ protocol: null,
slashes: null,
auth: null,
host: null,
@metamatt
metamatt / shell.txt
Created July 23, 2014 06:37
errors upgrading Discourse 0.9.6.4 to 0.9.9.13
discourse@chunkalicious:/var/www/discourse$ RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ENV=production bundle exec rake db:migrate
WARNING: --------------------------------------------------------------------------
You are running an old version of bundler, please update by running: gem install bundler
WARNING: --------------------------------------------------------------------------
You are running an old version of bundler, please update by running: gem install bundler
rake aborted!
@metamatt
metamatt / pings
Created June 22, 2014 05:27
San Francisco ISP latency
2014/06/21 (10:23pm on a saturday night, maybe bad case for monkeybrains):
astound:
wormhole:~# ping -I eth0.101 204.195.74.1
PING 204.195.74.1 (204.195.74.1) from 204.195.74.x eth0.101: 56(84) bytes of data.
64 bytes from 204.195.74.1: icmp_req=1 ttl=64 time=9.76 ms
64 bytes from 204.195.74.1: icmp_req=2 ttl=64 time=7.21 ms
64 bytes from 204.195.74.1: icmp_req=3 ttl=64 time=10.3 ms
64 bytes from 204.195.74.1: icmp_req=4 ttl=64 time=9.39 ms