This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function is_on_campus($IP = false) { | |
// If no IP is passed grab it from $_SERVER[] | |
$IP = $IP ? $IP : $_SERVER['REMOTE_ADDR']; | |
// Convert IP to long integer | |
$IPnum = ip2long($IP); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.clearfix:before, | |
.clearfix:after { | |
content: ""; | |
display: table; | |
} | |
.clearfix:after { | |
clear: both; | |
} | |
.clearfix { | |
*zoom: 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// debugging technique | |
// via: http://www.learncomputer.com/javascript-tricks-you-may-not-know/ | |
function AssertException( msg ) { | |
this.msg = msg; | |
} | |
AssertException.prototype.toString = function() { | |
return 'AssertException: ' + this.msg; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo tcpdump -i en0 -n -s 0 -w traffic.pcap tcp or port 53 | |
# see code.google.com/p/pcaphar/wiki/CaptureMobileTraffics | |
# NB: en0 is for ethernet connections, en1 for Airport | |
# see also support.apple.com/kb/HT3994 | |
# can analyze .pcap output with pcapperf.appspot.com/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
// php 5 | |
print_r( get_headers( "http://example.com", 1 ) ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function( $ ) { | |
var title, authors, price, url, | |
loc = document.location; | |
title = $( '#btAsinTitle' ).text().replace( /\s\[(Paperback|Hardcover|Bargain Price|Mass Market Paperback)\]/g, '' ); | |
// authors' names, skip over role e.g. (editor) | |
if ( $( '.contributorNameTrigger' )[ 0 ] ) { | |
if ( $( '.contributorNameTrigger' ).length > 1 ) { | |
authors = $( '.contributorNameTrigger a' )[ 0 ].text(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# put this in your .bash_profile | |
if [ $ITERM_SESSION_ID ]; then | |
export PROMPT_COMMAND='echo -ne "\033];${PWD##*/}\007"; ':"$PROMPT_COMMAND"; | |
fi | |
# Piece-by-Piece Explanation: | |
# the if condition makes sure we only screw with $PROMPT_COMMAND if we're in an iTerm environment | |
# iTerm happens to give each session a unique $ITERM_SESSION_ID we can use, $ITERM_PROFILE is an option too | |
# the $PROMPT_COMMAND environment variable is executed every time a command is run | |
# see: ss64.com/bash/syntax-prompt.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- just replace {{id}} with the video's ID | |
e.g. 9bZkp7q19f0 --> | |
<div style="width:100%;position:relative;padding:0;padding-top:75%"> | |
<iframe | |
style="position:absolute;top:0;left:0;width:100%;height:100%;" | |
src="http://www.youtube-nocookie.com/embed/{{id}}?rel=0" | |
frameborder="0" allowfullscreen mozallowfullscreen webkitallowfullscreen> | |
</iframe> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Top 10 BASH commands used | |
# from stackoverflow.com/questions/68372/what-is-your-single-most-favorite-command-line-trick-using-bash#answer-68390 | |
function top10() { | |
history | awk 'BEGIN {FS="[ \t]+|\\|"} {print $3}' | sort | uniq -c | sort -nr | head | |
} | |
1393 gs - alias for git status | |
1272 g - alias for git | |
1121 l - alias for ls -l | |
1003 - can't explain this...why would an empty space show up as a command? Bug in the top10 function maybe |