I've gotten tired of doing the :setlocal tabstop=... dance every time I start editing a file from someone who has their own unique feelings about how wide tabs should be... So I've written two little functions which make it easy to change a buffer's tab mode:
For example, when I start editing something written by someone who believes spaces are evil and tabs should be five spaces wide, I just need to :call HardTabs(5).
In case of Wikimergency (removing Wikipedia's blackout)
January 18, 2012 at 02:06 AM | Uncategorized | View CommentsHere's a bookmarklet that will remove the SOPA blackout overlay from Wikipedia:
javascript:(function(){document.getElementById("mw-sopaOverlay").style.display = "none"; var ids = ["mw-page-base", "mw-head-base", "content", "mw-head", "mw-panel", "footer"]; for (var i = 0; i < ids.length; i += 1) document.getElementById(ids[i]).style.display = "block";})()
Loading Google Closure libraries from Node.js
January 10, 2012 at 01:24 AM | JavaScript | View CommentsWhile developing remora (which will be released "soon") I had to load Google Closure libraries from Node.js. As it turns out, I'm the first one who has had to do this, so a blog post seemed in order.
I've loaded my Closure library in Node by creating a Node module which loads Closure's base.js, tells Closure how to load JavaScript files, loads my Closure library, then exports everything (the goog name space and my namespace) through module.exports.
First, an execfile function is needed, which will load and evaluate a JavaScript file using a particular namespace:
var vm = require("vm");
var fs = require("fs");
function execfile(path) {
var data = fs.readFileSync(path);
vm.runInThisContext(data, path);
}
Note: for various reasons (one of which being that you can't control the value of 'this' from the 'vm' module) vm.runInThisContext must be used to load the scripts into the global context. Trying to load the into a sandbox seems to fail for reasons I can't fully explain yet.
Next, the Closure base.js and deps.js files are loaded and CLOSURE_IMPORT_SCRIPT is set to a thin wrapper around execfile:
var base_basedir = "../src/browser/";
execfile(base_basedir + "base.js");
execfile(base_basedir + "deps.js");
goog.global.CLOSURE_IMPORT_SCRIPT = function(path) {
execfile(base_basedir + path);
return true;
};
Now Closure libraries which use goog.require(...) and goog.provide(...) can be loaded:
execfile("../src/remora.js");
(note: only the base library needs to be loaded; its dependencies will be taken care of by goog.require(...)).
Normal JavaScript packages can also be loaded:
execfile("../libs/underscore-1.2.3.js");
Finally, module.exports is set:
module.exports = {
goog: GLOBAL.goog,
remora: GLOBAL.remora,
};
Note: because Closure scripts expect that require/provide will inject items into the global namespace, the global names created (ex, goog and remora) cannot be deleted from the global namespace.
And that's all there is to it. This file can now be loaded like any other Node module (ex, var my_closure_library = require("./closure_compat.js")).
For a complete example, see remora/src/node/remora.dev.js.
I'm thinking about buying a 200+ GB SSD for my laptop, and this post summarizes my research. Note that it is current as of November 22, 2011 and will likely be irrelevant by 2012.
tl;dr The Corsair Force GT seems to be the fastest choice with Crucial m4 coming in a fairly close second. Data on failure rates for these drives/controllers has been hard to find, though, and all signs point to Intel drives being the most reliable (but also most expensive and slowest).
TechReport's SSD performance review which @samstokes sent me, which seems to find the two aforementioned drives to have the best performance, with the Corsair Force Series 3 making a decent showing as well. It also suggests that the Intel 500 series is a bit slower and significantly more expensive than the competition.
Tom's Hardware investigation on SSD reliability suggests that Intel's SSDs are much more reliable (specifically their X25-M series; a sentiment I've read in other places too), but it doesn't compare their failure rates to other manufacturers because "those are the drives that big businesses currently trust the most".
Friends on Twitter and Facebook generally recommended the m4.
It's also worth noting that I've read quite a few posts similar to The Hot/Crazy Solid State Drive Scale which suggest that failures can be fairly common. These posts have mostly been more than six months old, though, so I'm hoping that most of these problems have been sorted out in newer drives (it seems that there are often issues which can be fixed by a software update).
The net result is that I'm probably going to get a Force GT or m4, which ever I can find for a reasonable price from a local retailer with a good return policy.
Disclaimer: what you see is what you get. I've done enough research to convince myself that an SSD isn't a terrible idea, but that's definitely far from enough research to objectively show that an SSD isn't a terrible idea. Also, I've included links to Amazon for two reasons: 1) because prices change so often that quoting them here wouldn't be that useful, and 2) I've just setup a fancy affiliate account, so I stand a small chance of making a small amount of money from them.
howto: running the wifi and power at medium sized tech events
November 07, 2011 at 01:32 PM | Events | View CommentsBecause I've done it a few times now and picked up a few tricks, I thought I would write a checklist for anyone who needs (or wants) to run the wifi and power at a medium sized (10 - 100 people) tech event.
I hope that this checklist will be a useful for events like Software Carpentry or Ladies Learning Code, as it will give someone with some networking knowledge [0] the nuts-and-bolts they need to setup and run a great (or at least functional) network.
I've published this document as a Gist on GitHub to make updates easy.
The document: Wifi and power for medium sized tech events: https://gist.github.com/1346886
| [0] | anyone who knows the function of DHCP and the meaning of "default gateway" should be fine. |