Skip to content

Instantly share code, notes, and snippets.

View davidwkeith's full-sized avatar

David W. Keith davidwkeith

View GitHub Profile
@davidwkeith
davidwkeith / index.html
Last active November 7, 2024 19:03
NOTE: This was a great hack in days gone by, but now both Apple and Google have improved their support for custom protocol handlers. Licensed under the WFTPL http://www.wtfpl.net/txt/copying/
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>App Redirection</title>
</head>
<body>
<!--
NOTE: This was a great hack in days gone by, but now both Apple and Google have improved their support for custom
protocol handlers.
@davidwkeith
davidwkeith / localization_helper.js
Created July 11, 2012 21:50
Localization Helper for Ember.js's Handlebars
Handlebars.registerHelper('loc', function(property, fn) {
var str;
// we are bound to a value, it is now the context
if (fn.contexts && typeof fn.contexts[0] === 'string') {
str = fn.contexts[0];
// Convention, start all localization keys with _
} else if (property[0] === '_') {
str = property;
@davidwkeith
davidwkeith / create_element.js
Created June 10, 2013 00:33
Example of document.createElement enhancement
// not sure how to detect this yet, stay tuned or leave a comment
window.document._createElement = window.document.createElement;
window.document.createElement = function(name, attributes) {
if (typeOf attributes === 'string') {
// Chrome adds an undefined 'is' attribute for the second arg, why is this?
// Chrome is also throwing a TypeError for any third arg I can think of (number, string, object)
return window.document._createElement(arguments);
} else {
var elm = window.document._createElement(name);

Keybase proof

I hereby claim:

  • I am davidwkeith on github.
  • I am dwkeith (https://keybase.io/dwkeith) on keybase.
  • I have a public key whose fingerprint is 8AEE 1308 A48E C6BE 885B 89CD 7208 DB57 1364 E5E5

To claim this, I am signing this object:

@davidwkeith
davidwkeith / flickering.rb
Created February 6, 2016 21:09
Flickering candle effect for Halloween
require 'hue'
CANDLE_COLOR_RANGE = [*2000..2200] # Kelvin, 2000K is lowest Hue can do
CANDLE_BRIGHTNESS_RANGE = [*20..52]
bridge = Hue.application
candle = Hue::Bulb.new(bridge, 1)
candle.on if candle.off?
Verifying that "davidwkeith.id" is my Blockstack ID. https://onename.com/davidwkeith
@davidwkeith
davidwkeith / gosemver.go
Created September 27, 2018 17:31
Convert go version strings to semver compliant strings
package main
import (
"fmt"
"runtime"
"strings"
"github.com/coreos/go-semver/semver"
)