This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var regex = /^ *<\w+(?!:\/|@)\b(?:"[^"]*"|'[^']*'|[^>])*?> *(?:\n{2,}|\s*$)/; | |
var str = '' | |
+ '<div class="hero-unit">\n' | |
+ ' <img src="img/hello_world.png" style="misc: properties;">\n' | |
+ ' <div>\n' | |
+ ' <h1>hello world</h1>\n' | |
+ ' <p>hello world.</p>\n' | |
+ ' <p><a class="hello world" href="#!hello">hello world</a></p>\n' | |
+ ' </div>\n' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* pocketfm | |
* Pocket-sized File Manager | |
* Uses plain html to be as simple as possible | |
* Code is messy, needs revision and needs | |
* native mv, rm, cp implementations | |
* Copyright (c) 2011, Christopher Jeffrey (MIT License) | |
*/ | |
process.title = 'pocketfm'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# $ echo "console.log('hello world')" | runjs | |
runjs() { | |
cat | xargs -0 node -e | |
} | |
# usage: | |
# $ echo "hello world" | jsrx "/h\w+/g" "hi" | |
jsrx() { | |
local str=$(cat | sed "s/\\\/\\\\\\\/g" \ | |
| sed "s/'/\\\'/g" | sed ':a;N;$!ba;s/\r\n\|\n/\\n/g') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void | |
get_frame_extents(Display *dpy, Window w, int *top) { | |
long *extents; | |
Atom actual_type; | |
int actual_format; | |
unsigned long nitems, bytes_after; | |
unsigned char *data = NULL; | |
int result; | |
*top = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# easy manipulation of archives for people | |
# who don't like archivers or file managers | |
# copyright (c) 2011, christopher jeffrey | |
LIST= | |
EXTRACT= | |
CREATE= | |
ENCRYPT= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// small script i wrote to get strong randomness in node | |
// putting it here so i dont lose it | |
// copyright (c) 2011, christopher jeffrey, mit license, etc. | |
// example output: | |
// urandom: 0.17843490773309834 | |
// Math.random: 0.7067500613629818 | |
// random: 0.3154916005012327 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs') | |
, marked = require('marked'); | |
var text = fs.readFileSync(__dirname + '/test.md', 'utf8'); | |
var two = function(str) { | |
var tokens = marked.lexer(str) | |
, paragraphs = 0 | |
, i = 0 | |
, token; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a poem about coffeescript in the style of the lord of the rings: | |
one does not simply walk into coffeescript | |
its syntax is guarded by more than just ruby devs | |
and the significant whitespace is ever present | |
it is a wasteland barren of curly braces | |
- riddled with class syntax, postfix conditionals, and operator aliases | |
the very code you write, is a poisonous fume | |
not with 10,000 men who knew javascript could you do this |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var bench = function(func, t) { | |
var start = new Date() | |
, i = t || 100000; | |
while (i--) func(1, 2, 3); | |
console.log('%s: %sms', func.name, new Date() - start); | |
}; | |
var slice = Array.prototype.slice; | |
bench(function _slice() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ignore the shims | |
// the original (slow) version | |
var Buffer1 = (function() { | |
var assert = {}; | |
var fail = function() { throw new Error('assertion failed'); }; | |
var Buffer = function() { this.length = 100; }; | |
Buffer.prototype.writeUInt32 = function(value, offset, endian) { | |
var buffer = this; |