Skip to content

Instantly share code, notes, and snippets.

@chbrown
chbrown / transformerrs.js
Created May 28, 2013 19:41
Node.js stream.Transform bug / oddity.
var util = require('util');
var stream = require('stream');
var fs = require('fs');
// # 1. With objectMode: true
var ObjectParser = function(opts) {
stream.Transform.call(this, {
decodeStrings: true, // Writable option, ensure _transform always gets a Buffer
objectMode: true // Readable option, .read(n) should return a single value, rather than a Buffer
@chbrown
chbrown / zpop_command.js
Created November 2, 2012 05:00
ZPOP for Node.js redis
redis.RedisClient.prototype.zpop = function(key, withscores, callback) {
if (callback === undefined && typeof(withscores) === 'function') callback = withscores;
this.multi().
zrange(key, 0, 0, withscores).
zremrangebyrank(key, 0, 0).
exec(function(err, replies) {
if (callback) callback(err, replies ? replies[0] : null);
});
};
@chbrown
chbrown / README.md
Created October 21, 2012 17:23
Google Faster

Problem and Motivation

Google uses onmousedown="..." in-line javascript to track outgoing clicks on their search results page. Anchor tags (<a>) handle the onmousedown event before handling the href, so hijacking the user's intent is quite easy. This is usually a good thing, because Google uses clickthroughs to measure success of their search results, and the better Google is at getting me good search results, the happier I am.

But lately, I have been using a slower than usual internet connection when at home, and since apparently nobody at Google tests the usability of anything Google on a slower than 1T connection, they simply don't give a shit that SPDY sometimes breaks down for slow connections like mine. The solution? Pretend like I don't have javascript. This will let me click through with clean hrefs, like with normal links on normal websites. They should be measuring mouseovers anyway, not mousedown's.

Also, this will give you a little more privacy.

Instructions

@chbrown
chbrown / gist:3715024
Created September 13, 2012 15:18
20120912T22 -- Morris
20120912T22 Morris Sadek, anti Muslim Bush supporter sent film around. Now this..Iran plans protests over anti-Islam film. http://t.co/cRxwfW5m Morris Sadek, anti Muslim Bush supporter sent film around. Now this..Iran plans protests over anti-Islam film. http://t.co/cRxwfW5m Morris Sadek, anti Muslim Bush supporter sent film around. Now this..Iran plans protests over anti-Islam film. http://t.co/cRxwfW5m RT @Zeinobia: Egyptian Christian ladies beat Morris Sadek with their shoes in Washington D.C , long live Egyptian traditions and women :)) RT @Zeinobia: Egyptian Christian ladies beat Morris Sadek with their shoes in Washington D.C , long live Egyptian traditions and women :)) RT @Zeinobia: Egyptian Christian ladies beat Morris Sadek with their shoes in Washington D.C , long live Egyptian traditions and women :)) RT @Zeinobia: Egyptian Christian ladies beat Morris Sadek with their shoes in Washington D.C , long live Egyptian traditions and women :)) RT @KKoz22: Morris Sadek, anti Muslim Bush supporter sen
@chbrown
chbrown / gist:3227782
Created August 1, 2012 15:22
Sublime Text 2 Freeze on sshfs connection loss.
Date/Time: 2012-08-01 15:20:38 +0000
OS Version: 10.8 (Build 12A269)
Architecture: x86_64
Report Version: 11
Command: Sublime Text 2
Path: /Applications/Sublime Text 2.app/Contents/MacOS/Sublime Text 2
Version: Version 2.0.1, Build 2217 (2217)
Parent: launchd [142]
@chbrown
chbrown / jquery.flags.js
Created May 25, 2012 03:15
jQuery Flags plugin
(function($) {
$.fn.measureBox = function() {
return {
width: this.width() +
parseInt(this.css('border-left-width'), 10) +
parseInt(this.css('border-right-width'), 10) +
parseInt(this.css('padding-left'), 10) +
parseInt(this.css('padding-right'), 10),
height: this.height() +
parseInt(this.css('border-top-width'), 10) +
@chbrown
chbrown / gist:1430951
Created December 4, 2011 18:40
Jabberwockish
Input: vorpal ny mek gimble oof raths ny outgrabe
n np\n (np\np)/(s\pp) (s\np)\pp (s\(s\np))/np n np\n s\np
- ---- -------------- --------- ------------- - ---- ----
np np
-------- --------
s\(s\np)
------------------------
s\pp
------------------------------------
@chbrown
chbrown / gist:1318893
Created October 27, 2011 06:11
Amulet tut
Hi,
There are a few tests for amulet, yes.
In the tests/ directory, run these:
node spec_test.js --ignore-whitespace
node spec_test.js --ignore-whitespace --extended
I use amulet in a couple of production cases.
@chbrown
chbrown / gist:1283420
Created October 13, 2011 04:54
Arrows for Derya
\documentclass{report}
\usepackage{qtree,gb4e}
\usepackage{tree-dvips}
\begin{document}
Mary put the books on the shelf on the table.
\Tree [.CP {} [.C\1 {C\\$\emptyset$}
@chbrown
chbrown / Trees1&2
Created September 29, 2011 02:36 — forked from anonymous/Trees1&2
SyntaxTrees
\item Abelard has written a volume of poems in Latin for H\'elo\"ise.
\Tree
[.CP
{\phantom{C}}\qsetw{.5cm}
[.TP
[.NP
{\phantom{D}}\qsetw{.5cm}
[.N\1
{N\\Abelard}