Skip to content

Instantly share code, notes, and snippets.

View Marak's full-sized avatar

Marak

View GitHub Profile
@Marak
Marak / whitespace
Created August 19, 2010 22:43 — forked from jpignata/whitespace
#!/usr/bin/env ruby
# script/whitespace
#
# Strips whitespace from any files modified in git
# Also:
# - converts tabs to spaces
# - ensures a single newline at the end
class WhitespaceProcessor
def self.process(code)
var noc = require('noc');
var job = noc.createJob('install node.js on ubuntu');
job.addTask(function (server) {
// Some javascript code .. maybe:
// server.mkdir(....)
});
var item = { "hdbarcode": hdbarcode, "description": description };
// 2nd argument is callback
getDescription(item.hdbarcode, function(upcDescrip){
db.save(null, item, function (err, meta) {
// This does not change item on line 1. Why?
item.key = meta.key;
sys.puts('saved ' + JSON.stringify(item) + ' as '+ meta.key);
// tell client
set dirty(value) {
this.ascend(function(node) { node._dirty = value; });
},
function benchmark(method, times, name){
//See http://gist.github.com/227048
var startTime = (new Date()).getTime(), endTime;
while(times--){
method();
}
endTime = (new Date()).getTime();
console.log(name, endTime - startTime);
}
var x = 1, y = 0;
// HttpClient only calls 'success' once.
var respondsWith = function (code, body) {
var context = {
topic: function () {
var req = this.context.name.split(/ +/), // ["POST", "/"]
method = req[0].toLowerCase(), // "post"
path = req[1], // "/"
self = this;
new HttpClient({
@Marak
Marak / insanity
Created June 18, 2010 04:51 — forked from heapwolf/insanity
function doit() {
INSANITY:
for(var i=1; i < 20; i++) {
if(i == 10) {
continue INSANITY;
}
console.log(i);
var intag = false, ret = [], tmpbuf = "", endtag = false;
for (var i=0; i<html.length; i++)
{
var char = html[i];
if (char === '<') {
intag = true;
if (tmpbuf.length > 0) {
ret.push(tmpbuf.replace("/",""));
var intag = false, ret = [], tmpbuf = "", endtag = false;
for (var i=0; i<html.length; i++)
{
var char = html[i];
if (char === '<') {
intag = true;
if (tmpbuf.length > 0) {
ret.push(tmpbuf.replace("/",""));
var d = $("#foo")[0].attributes;
for(var i = 0; i < d.length; i++) {
print(d.item(i).value);
}