Skip to content

Instantly share code, notes, and snippets.

View zaach's full-sized avatar
🎯
Focusing

Zach Carter zaach

🎯
Focusing
View GitHub Profile
@zaach
zaach / qsa
Created June 26, 2012 23:46
gcli command
gcli.addCommand({
name: 'qsa',
description: 'perform querySelectorAll on the current document and return number of matches',
params: [
{
name: 'query',
type: 'string',
description: 'CSS selectors seperated by comma',
}
@zaach
zaach / globals
Created June 6, 2012 21:50
jshint lib/ | grep "not defined"
lib/browserid/fake_verification.js: line 15, col 1, 'logger' is not defined.
lib/browserid/fake_verification.js: line 16, col 1, 'wsapi' is not defined.
lib/browserid/fake_verification.js: line 18, col 1, 'logger' is not defined.
lib/browserid/fake_verification.js: line 19, col 1, 'logger' is not defined.
lib/browserid/fake_verification.js: line 25, col 23, 'wsapi' is not defined.
lib/browserid/fake_verification.js: line 25, col 42, 'resp' is not defined.
lib/browserid/views.js: line 181, col 3, 'REDIRECTS' is not defined.
lib/browserid/views.js: line 192, col 19, 'REDIRECTS' is not defined.
lib/browserid/views.js: line 197, col 13, 'REDIRECTS' is not defined.
lib/db/mysql.js: line 92, col 9, 'dne' is not defined.
error: (signup) Error: connect EMFILE
error: (signup) can't verify: Error: connect EMFILE
error: (signup) can't authenticate: Error: connect EMFILE
error: (signup) Error: connect EMFILE
error: (signup) can't authenticate: Error: connect EMFILE
error: (signup) can't authenticate: Error: connect EMFILE
error: (signup) failed to complete user creation: Error: connect EMFILE
error: (signup) failed to complete user creation: Error: connect EMFILE
error: (signup) can't verify: Error: connect EMFILE
error: (signup) can't verify: Error: connect EMFILE
@zaach
zaach / po2json.js
Created February 4, 2012 19:59
PO parser from http://jsgettext.berlios.de/lib/Gettext.js adapted for Node.js and modified to be more like po2json.pl
#!/usr/bin/env node
/*
PO parser from http://jsgettext.berlios.de/lib/Gettext.js
adapted for Node.js and modified to be more like po2json.pl
- Zach Carter <zcarter@cse.usf.edu>
*/
/*
Pure Javascript implementation of Uniforum message translation.
@zaach
zaach / 0_new.md
Created January 22, 2012 23:15
New Jison 0.3 features

Some improvements have been made for parser and lexer grammars in Jison 0.3 (demonstrated in the FlooP/BlooP example below.)

For lexers:

  • Patterns may use unquoted characters instead of strings
  • Two new options, %options flex case-insensitive
  • flex: the rule with the longest match is used, and no word boundary patterns are added
  • case-insensitive: all patterns are case insensitive
  • User code section is included in the generated module
@zaach
zaach / person.js
Created August 14, 2011 03:46
An example from http://yehudakatz.com/2011/08/ adapted to use the <| operator
var fromPrototype = function(prototype, object) {
var newObject = Object.create(prototype);
for (var prop in object) {
if (object.hasOwnProperty(prop)) {
newObject[prop] = object[prop];
}
}
};
@zaach
zaach / required.js
Created July 24, 2011 02:05
Finds the names of all modules required in the file.
var JSONSelect = require("JSONSelect");
var Reflect = require("reflect");
var ast = Reflect.parse(read(__filename));
var required = JSONSelect.match('.callee:has(:root > .name:val("require")) ~ .arguments :first-child .value', ast);
// ["JSONSelect", "reflect", "fs", "path"]
function read (path) {
return require("fs").readFileSync(require("path").resolve(path), "utf8");
var source = require('fs').readFileSync(require('path').join(process.cwd(), process.argv[2]), "utf8");
require("./reflect.js").parse(source);
@zaach
zaach / dn
Created June 3, 2011 03:54
simple script for daily note taking
#!/usr/bin/env sh
# for daily note taking and todo enumerating
if [ ! -e ~/.daily-note ]
then mkdir ~/.daily-note
fi
cd ~/.daily-note
FILE=`date "+%Y-%m-%d"`
@zaach
zaach / handlebars.l
Created December 13, 2010 00:18
Handlebars.js lexer using start conditions
%x mu
%%
.+?/("{{") { this.begin('mu'); return 'CONTENT'; }
/("{{") { this.begin('mu'); }
.+ { return 'CONTENT'; }
<mu>"{{>" { return 'OPEN_PARTIAL'; }
<mu>"{{#" { return 'OPEN_BLOCK'; }