Skip to content

Instantly share code, notes, and snippets.

@twolfson
twolfson / health.js
Created September 27, 2012 03:50
Health for your server
// Health page (attribution to dshaw)
var pkg = require('./package.json');
version = pkg.version;
app.get('/health', function (req, res) {
var health = {
'version': pkg.version,
'pid': process.pid,
'memory': process.memoryUsage(),
'uptime': process.uptime()
};
@twolfson
twolfson / .bashrc
Created October 2, 2012 05:36
Sexy bash script - Cool color flavored
## THIS READS AS user at device in pwd on git_branch
# Sexy Bash Prompt, inspired by "Extravagant Zsh Prompt"
# Screenshot: http://img.gf3.ca/d54942f474256ec26a49893681c49b5a.png
# A big thanks to \amethyst on Freenode
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then export TERM=gnome-256color
elif [[ $TERM != dumb ]] && infocmp xterm-256color >/dev/null 2>&1; then export TERM=xterm-256color
fi
@twolfson
twolfson / index.js
Created October 3, 2012 06:17
Trying spaces over zeroes for led-matrix
" 11 11 ",
"1 11 1",
"1 1",
"1 1",
" 1 1 ",
" 1 1 ",
" 11 ",
" "
vs
@twolfson
twolfson / .gitignore
Created November 2, 2012 06:14
globstar-test
/node_modules
@twolfson
twolfson / index.js
Created November 10, 2012 04:19
Health watcher
// Grab the current pid
$.get('/health', function (health) {
var pid = health.pid;
// Watch the health to see if it changes
setInterval(function () {
// If it does, refresh the page
$.get('/health', function (health) {
if (health.pid !== pid) {
location.reload();
@twolfson
twolfson / geolocation.js
Created November 11, 2012 00:05
geolocation lookup that accepts an error-first callback
// Asynchronous retrieval of coordinates
function getCoordinates(cb) {
// Grab geolocation from the navigator
var geolocation = window.navigator.geolocation;
// If geolocation exists, start fetching location
if (geolocation) {
geolocation.getCurrentPosition(function (position) {
cb(null, position.coords);
}, cb);
@twolfson
twolfson / latLngNormalization.js
Created November 12, 2012 05:25
Latitude and longitude normalization
// ASIDE: This was built during NodeKO 2012 -- hence the window.'s lying around
// Define latLngPadder
function normalizeLat(lat) {
var latStr = lat + '';
// Guarantee a decimal place in the number
if (latStr.indexOf('.') === -1) {
latStr = latStr + '.';
}
@twolfson
twolfson / LICENSE.txt
Created November 12, 2012 06:57 — forked from 140bytes/LICENSE.txt
Geolocation lookup that accepts an error-first callback
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE http://twolfson.com/
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@twolfson
twolfson / index.js
Created November 15, 2012 20:26
Grab total points from JIRA
$.get('{{XML_LOCATION}}', function (data, status) {
if (status === 'success') {
var $data = $(data),
$itemArr = $data.find('item'),
points = $itemArr.map(function () {
var $item = $(this),
$customFields = $item.find('customfield'),
$storyPointsField = $customFields.filter('{{STORY_POINT_FILTER'),
// $storyPointsField = $customFields.filter('[id="customfield_10004"]'),
storyPoints = +($storyPointsField.find('customfieldvalue').text() || 0);
@twolfson
twolfson / index.md
Created November 19, 2012 09:00
Thoughts on non-innerHTML HTML to DOM interpretter

I am probably never going to get to this so I am documenting my thoughts publicly.

Methods to try

  • Stack parse
    • Consult the stack methodology that json2.js uses (should be on Google Code)
  • Resig (HTML2XML) + jQuery (XMLInterpretter)

Make a spec