This file contains hidden or 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
import os | |
import apsw | |
import pdb | |
class SqliteQueue(object): | |
_create = 'CREATE TABLE IF NOT EXISTS queue (id INTEGER PRIMARY KEY AUTOINCREMENT, item TEXT)' | |
_append = 'INSERT INTO queue (item) VALUES (?)' | |
_pop_get = 'SELECT id, item FROM queue ORDER BY id LIMIT 1' | |
_pop_del = 'DELETE FROM queue WHERE id = ?' |
This file contains hidden or 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
listOfDelimitedStringsToTree = (lines, delimiter) -> | |
stringTreeToObjectTree = (root) -> | |
childNodes = [] | |
for name, value of root | |
# path is just metadata for this whole process | |
# so we skip it | |
if name isnt "path" | |
node = | |
name: name | |
children: stringTreeToObjectTree(value) |
This file contains hidden or 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
/* Takes a list ofdelimited strings, where the delimiter is intended to imply | |
* a hierarchy ( somewhat like a file system path ) and turns it into | |
* a tree-like structure consisting of nodes looking something like | |
* { name: "", children: [] } | |
* The tree starts at the root node, which is ( no foolin' ) called | |
* root. So the top (root) node is: | |
* { name: "root", children: [xxx] } | |
*/ | |
function listOfDelimitedStringsToTree(lines, delimiter){ | |
function stringTreeToObjectTree(root){ |
This file contains hidden or 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
/* The idea here is that we take something that's formatted like a query string, and | |
return a dictionary (object) it represents | |
*/ | |
function qsLikeToObj(qsLike){ | |
var obj = {}; | |
qsLike.replace( | |
new RegExp("([^?=&]+)(=([^&]*))?", "g"), | |
function($0, $1, $2, $3) { obj[$1] = $3; } | |
); | |
return obj; |
This file contains hidden or 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
#! /usr/bin/env Rscript | |
a <- scan(file("stdin"), c(0), quiet=TRUE); | |
cat(length(a), sd(a), min(a), max(a), mean(a), median(a), "\n"); |
This file contains hidden or 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
// name is still bad, have yet to figure what would be more correct | |
// sign change differences make re-using the TimezoneOffset verbage | |
// confusing | |
Date.prototype.getTimezoneOffsetHoursAndMinutes = function(){ | |
// offset in minutes | |
var tzo = this.getTimezoneOffset(); | |
// determine 'direction' from GMT we are | |
// if offset is positive, we're 'in the past' | |
var behindGMT = tzo > 0; | |
// work in positive |