Skip to content

Instantly share code, notes, and snippets.

@weisjohn
weisjohn / implementation of TriangleClassifier
Created January 18, 2012 16:49
code from my first visit to Dayton Clean Coders, an implementation of the kata at http://onestepback.org/vital_testing/
// implementation of the challenge found here: http://onestepback.org/vital_testing/
var TriangleClassifier = {
valid : function (args) {
var sides = [ args[0], args[1], args[2] ];
if (args.length != 3) {
return false;
@weisjohn
weisjohn / gist:1793873
Created February 10, 2012 23:09
the Video.JS way of protecting console.* statements
_V_.log = function() {
_V_.log.history = _V_.log.history || [];
_V_.log.history.push(arguments);
if (window.console) {
arguments.callee = arguments.callee.caller;
var newarr = [].slice.call(arguments);
(typeof console.log === "object" ? _V_.log.apply.call(console.log, console, newarr) : console.log.apply(console, newarr))
}
};
(function(b) {
@weisjohn
weisjohn / gist:1895291
Created February 23, 2012 22:01
a simple jQuery based ticker
// a simple utility function for pretty printing
function pad(number, length) {
var str = '' + number;
while (str.length < length) {
str = '0' + str;
}
return str;
}
@weisjohn
weisjohn / recordAnalytics.js
Created February 28, 2012 18:35
CoreMetrics Library Wrapper
 /**
* recordAnalytics( {
* 'cm': {
* 'pageid': 'your/tag/here', // required
* 'searchstring': 'your search string', // optional
* 'categoryid': 'your_category_id' // optional
* 'type' : 'type of tag' // optional
* },
* });
*
@weisjohn
weisjohn / tounch_munge.js
Created March 19, 2012 14:42
basic touch/mouse events + munging
// feature detection
isTouch = "ontouchstart" in window;
InputHandler = {
startEventType : isTouch ? "touchstart" : "mousedown",
moveEventType : isTouch ? "touchmove" : "mousemove",
endEventType : isTouch ? "touchend" : "mouseup",
isTouchDevice : isTouch,
// normalize an event object generated by a select
@weisjohn
weisjohn / normalized.html
Created May 21, 2012 07:21 — forked from scottkellum/normalized.html
pixel normalization
<!doctype html>
<html>
<head>
<!-- Encoding -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"></meta>
@weisjohn
weisjohn / gist:2962071
Created June 20, 2012 20:40
Page for displaying device orientation
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<title>Orientation Test</title>
<style>
body { text-align: center; }
@media all and (orientation:portrait) {
body { font-size: 35em; margin-top: .3em; }
}
@weisjohn
weisjohn / gist:2973551
Created June 22, 2012 15:39
git config --global core.excludesfile ~/.gitignore_global
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@weisjohn
weisjohn / .aliases
Created June 22, 2012 17:49
An alias that pretty-prints git logs as graphs
# this came from jtaby http://www.slideshare.net/jtaby/tools-and-techniques-for-faster-development slide 94
alias gl="git log --graph --pretty=format:'%Cred%h%Creset %C(cyan)%an%Creset - %C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative"
@weisjohn
weisjohn / gist:3009515
Created June 28, 2012 06:34
git push hook sample display
#!/bin/bash
$ git push
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 324 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: % Total % Received % Xferd Average Speed Time Time Time Current
remote: Dload Upload Total Spent Left Speed