Skip to content

Instantly share code, notes, and snippets.

View tmlbl's full-sized avatar

Tim tmlbl

View GitHub Profile
@tmlbl
tmlbl / xmlToJs.js
Last active August 29, 2015 14:14
xmltojs
// My attempt to make David Walsh's xmlToJson function work
// with libxmltojs. This reproduces the document tree but not
// the text inside in each node. There is a lot of data in these
// documents we are not using... I think we should stick to the
// xpath queries.
// Changes XML to JSON
function xmlToJson (xml) {
// Create the return object
var obj = {};
@tmlbl
tmlbl / output.txt
Last active August 29, 2015 14:14
Parsing Neighborhood Information from Zillow
[ { title: 'Makin\' It Singles',
name: 'Upper-scale urban singles.',
description: 'Pre-middle-age to middle-age singles with upper-scale incomes. May or may not own their own home. Most have college educations and are employed in mid-management professions.' },
{ title: 'Aspiring Urbanites',
name: 'Urban singles with moderate income.',
description: 'Low- to middle-income singles over a wide age range. Some have a college education. They work in a variety of occupations, including some management-level positions.' },
{ title: 'Bright Lights, Big City',
name: 'Very mobile singles living in the city.',
description: 'Singles ranging in age from early 20s to mid-40s who have moved to an urban setting. Most rent their apartment or condo. Some have a college education and work in services and the professional sector.' } ]
@tmlbl
tmlbl / montha.go
Created December 8, 2014 08:19
How to get time in past in Golang https://play.golang.org/p/ROTLEXldq4
package main
import (
"fmt"
"time"
)
func main() {
now := time.Now()
oneMonthAgo := time.Unix(now.Unix() - (60 * 60 * 24 * 30), 0)
@tmlbl
tmlbl / util.sh
Created November 8, 2014 20:27
Task runner utilities fr JS project
#!/bin/bash
# Run in mock production mode with docker
dockerEnv() {
mkdir -p images;
printf "Starting the mongodb container...\n";
docker run -d --name="spacedb" beshippable/dbbase;
printf "Starting the application container...\n";
docker run -v $(pwd):/app -p 8080:8080 -v $(pwd)/images:/img \
--name="spacecam" -e NODE_ENV=prod --link spacedb:db \
@tmlbl
tmlbl / runner.js
Last active January 23, 2020 19:52
Asynchronous test runner
module.exports = Runner;
function Runner() {
this.stack = [];
this.passed = 0;
this.failed = 0;
}
Runner.prototype.it = function (msg, test) {
this.stack.push(new Test(msg, test));
@tmlbl
tmlbl / fig.go
Created September 13, 2014 23:46
Basic implementation of fig syntax
// Implements fig syntax.
package main
import (
"gopkg.in/yaml.v1"
"io/ioutil"
"log"
)
var metaConfig MetaConfig
@tmlbl
tmlbl / hash.js
Created May 9, 2014 05:38
Simple hash function in JavaScript
String.prototype.hashCode = function(){
var hash = 0;
if (this.length == 0) return hash;
for (i = 0; i < this.length; i++) {
char = this.charCodeAt(i);
hash = ((hash<<5)-hash)+char;
hash = hash & hash; // Convert to 32bit integer
}
return hash;
}
# conky configuration
#
# The list of variables has been removed from this file in favour
# of keeping the documentation more maintainable.
# Check http://conky.sf.net for an up-to-date-list.
#
# For ideas about how to modify conky, please see:
# http://crunchbanglinux.org/forums/topic/59/my-conky-config/
#
# For help with conky, please see:
<?xml version="1.0" encoding="UTF-8"?>
<openbox_config xmlns="http://openbox.org/3.4/rc" xmlns:xi="http://www.w3.org/2001/XInclude">
<resistance>
<strength>10</strength>
<screen_edge_strength>20</screen_edge_strength>
</resistance>
<focus>
<focusNew>yes</focusNew>
<!-- always try to focus new windows when they appear. other rules do
apply -->
#---------------------------------------------
# TINT2 CONFIG FILE
#---------------------------------------------
# For more information about tint2, see:
# http://code.google.com/p/tint2/wiki/Welcome
#
# For more config file examples, see:
# http://crunchbanglinux.org/forums/topic/3232/my-tint2-config/
# Background definitions