Skip to content

Instantly share code, notes, and snippets.

@weisjohn
weisjohn / implementation of TriangleClassifier
Created Jan 18, 2012
code from my first visit to Dayton Clean Coders, an implementation of the kata at http://onestepback.org/vital_testing/
View implementation of TriangleClassifier
// 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 Feb 10, 2012
the Video.JS way of protecting console.* statements
View gist:1793873
_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 Feb 23, 2012
a simple jQuery based ticker
View gist:1895291
// 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 Feb 28, 2012
CoreMetrics Library Wrapper
View recordAnalytics.js
 /**
* 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 Mar 19, 2012
basic touch/mouse events + munging
View tounch_munge.js
// 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
View normalized.html
<!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 Jun 20, 2012 — forked from mattg/gist:1943615
Page for displaying device orientation
View gist:2962071
<!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 Jun 22, 2012
git config --global core.excludesfile ~/.gitignore_global
View gist:2973551
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@weisjohn
weisjohn / .aliases
Created Jun 22, 2012
An alias that pretty-prints git logs as graphs
View .aliases
# 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 Jun 28, 2012
git push hook sample display
View gist:3009515
#!/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
You can’t perform that action at this time.