Skip to content

Instantly share code, notes, and snippets.

🌲
lost in the woods

Tim Branyen tbranyen

🌲
lost in the woods
Block or report user

Report or block tbranyen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View doubletap-improved.js
function doubleTouch(element, callback) {
if ((!element && !callback) || (!callback && typeof element !== 'function')) {
return;
} else if (!callback && typeof element === 'function') {
callback = element;
element = document;
}
var taps = 0;
@tbranyen
tbranyen / string.format.js
Created Jun 27, 2011
safer string formatting
View string.format.js
// Inspired by http://bit.ly/juSAWl
// Augment String.prototype to allow for easier formatting. This implementation
// doesn't completely destroy any existing String.prototype.format functions,
// and will stringify objects/arrays.
String.prototype.format = function(i, safe, arg) {
function format() {
var str = this, len = arguments.length+1;
// For each {0} {1} {n...} replace with the argument in that position. If
@tbranyen
tbranyen / _usage.md
Last active Aug 1, 2019
OpenWeatherMap / Weather Icons integration
View _usage.md
  1. Include Weather Icons in your app: https://github.com/erikflowers/weather-icons

  2. Include the below JSON in your application, for example purposes, lets assume it's a global named weatherIcons.

  3. Make a request to OpenWeatherMap:

req = $.getJSON('http://api.openweathermap.org/data/2.5/weather?q=London,uk&callback=?');
@tbranyen
tbranyen / server.js
Last active Jul 28, 2019
backbone/node.js pushState enabled server
View server.js
// Require libraries
var os = require("os");
var fs = require("fs");
var readline = require("readline");
var cluster = require("cluster");
var express = require("express");
var site = express();
// Var up, bro
var i, read;
@tbranyen
tbranyen / _setup.sh
Created May 29, 2017
Web Components <3 JSDOM
View _setup.sh
npm i jsdom-wc@11.0.0-alpha-1
View github.sh
#!/bin/bash
#
# Copyright 2011, Tim Branyen @tbranyen <tim@tabdeveloper.com>
# Dual licensed under the MIT and GPL licenses.
#
# Automatically clone single or multiple repos into a folder,
# great for setting up a git projects folder.
#
# Install: curl https://gist.github.com/raw/902154/github.sh > /usr/local/bin/gh
# chmod +x /usr/local/bin/gh
@tbranyen
tbranyen / canvas.js
Created Feb 2, 2012
Lightweight canvas wrapper.
View canvas.js
// Basic Usage:
//
// var main = new Canvas({ elem: "canvas" }, function(options) {
// // Instantiate anything specific here...
// // Main draw loop
// this.draw = function() {
//
// };
// });
//
View git_profanity_check.js
#!/usr/bin/env node
// Copyright 2011, Tim Branyen @tbranyen <tim@tabdeveloper.com>
// Dual licensed under the MIT and GPL licenses.
// Script to detect cursewords in commit messages and provide the
// offending commit sha's.
// vim: ft=javascript
var git = require( 'nodegit' );
var curses = [ 'removed', 'inappropriate', 'swear', 'words' ]
@tbranyen
tbranyen / diffhtml.js
Last active Apr 24, 2019
diffHTML "Calculator" Experiment
View diffhtml.js
import { innerHTML, html } from 'https://unpkg.com/diffhtml/dist/es';
let a = 1;
let b = 2;
const updateA = ({ target }) => (a = Number(target.value), render());
const updateB = ({ target }) => (b = Number(target.value), render());
function render() {
innerHTML(document.body, html`
@tbranyen
tbranyen / backbone.collectioncache.js
Created Jun 4, 2012
Backbone.Collection caching by URL
View backbone.collectioncache.js
/*!
* backbone.collectioncache.js v0.0.2
* Copyright 2012, Tim Branyen (@tbranyen)
* backbone.collectioncache.js may be freely distributed under the MIT license.
*/
(function(window) {
"use strict";
// Dependencies
You can’t perform that action at this time.