Skip to content

Instantly share code, notes, and snippets.

View jhuttner's full-sized avatar

Joseph Huttner jhuttner

View GitHub Profile
@jhuttner
jhuttner / toggler.js
Created October 5, 2011 18:48
Easily change show/hide text on links that toggle DOM elements - by Joseph Huttner
function toggler(dom_element) {
var inner = dom_element.innerHTML;
var new_inner;
if (inner.indexOf('Show') !== -1) {
new_inner = inner.split('Show').join('Hide');
} else if (inner.indexOf('show') !== -1) {
new_inner = inner.split('show').join('hide');
} else if (inner.indexOf('hide') !== -1) {
new_inner = inner.split('hide').join('show');
@jhuttner
jhuttner / gist:1251710
Created September 29, 2011 19:37
My Code Review Submission
_oMyController.setListener('firstEvent secondEvent', function(data) {
if (data.is_second_event) {
// do something specific just to the second event
}
// do something common to both events
});
@jhuttner
jhuttner / demo.js
Created August 16, 2011 16:07
jquery demo
<select id="sel1">
<option>Eric</option>
<option>Joe</option>
</select>
<p id="eric" class="hidden">Hi, I'm eric</p>
<p id="joe" class="hidden">Hi, I'm joe</p>
$(document).ready(function(){
public static function indentJSON($json) {
$result = '';
$pos = 0;
$strLen = strlen($json);
//$indentStr = ' ';
//$newLine = "\n";
$indentStr = '&nbsp;&nbsp;&nbsp;&nbsp;';
$newLine = "<br/>";
for($i = 0; $i <= $strLen; $i++) { $char = substr($json, $i, 1); if($char == '}' || $char == ']') { $result .= $newLine; $pos --; for ($j=0; $j<$pos; $j++) { $result .= $indentStr; } } $result .= $char; if ($char == ',' || $char == '{' || $char == '[') { $result .= $newLine; if ($char == '{' || $char == '[') { $pos ++; } for ($j = 0; $j < $pos; $j++) { $result .= $indentStr; } } } return $result;
@jhuttner
jhuttner / store
Created June 7, 2011 19:06
Store last command to mac buffer
PUT AS TWO SEPARATE SCRIPTS: store.sh, and store.py.
USAGE: ./store.sh
#/!bin/bash
echo "Wait...."
history > /tmp/store
/home/jhuttner/store.py
cat /tmp/store2 | pbcopy
#!/bin/bash
ssh local pbcopy -
@jhuttner
jhuttner / drain.py
Created May 31, 2011 19:46
Drain the battery on your computer, via the Command Line.
#!/usr/local/bin/python
# If you have an n-core machine, open n terminals and run this script in each one.
def fib(n):
if n == 1 or n == 0:
return 1
else:
return fib(n-1) + fib(n-2)
@jhuttner
jhuttner / reconnect.sh
Created May 27, 2011 00:35
Make Juniper Network Connect suck less
#!/bin/bash
CNT=`ps -ef | grep -e Network | grep -v grep | wc -l`
if [ $CNT -eq 1 ]; then
kill `ps -ef | grep -e Network | grep -v grep | awk '{print $2}'`
fi
/Applications/Network\ Connect.app/Contents/MacOS/Network\ Connect &
var unbind = function($tab, by_type) {
/*
* var types = {
* 'click': ['#selector_one', '#selector_two'],
* 'delegate': ['#selector_three'],
* 'live': ['#selector_four']
* }
* unbind($geoTab, types);
*/
for (var i in by_type) {
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = blue bold