This file contains 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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains 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
$.QueryString = (function(a) { | |
if (a == "") return {}; | |
var b = {}; | |
for (var i = 0; i < a.length; ++i) { | |
var p = a[i].split('='); | |
if (p.length != 2) continue; | |
b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " ")); | |
} | |
return b; | |
})(window.location.search.substr(1).split('&')); |
This file contains 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
//$('form').values() or $('form').values(v) | |
$.fn.values = function(data) { | |
var els = $(this).find(':input').get(); | |
if (typeof data != 'object') { | |
// return all data | |
data = {}; | |
$.each(els, function() { | |
if (this.name && !this.disabled && (this.checked |
This file contains 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 chown -R $USER /usr/local |
This file contains 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
md5check(){ | |
MSG=$(md5 $1 | grep -e "= $2$") | |
if [ -z "$MSG" ]; then | |
echo "Failed" | |
else | |
echo $MSG "Match" | |
fi | |
} | |
usage: md5check <filename> <md5sum to match> |
This file contains 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
var events = (function() { | |
var topics = {}; | |
return { | |
sub: function(topic, listener) { | |
topics[topic] = topics[topic] || []; | |
var index = topics[topic].push(listener) - 1; | |
// Provide handle back for removal of topic |
This file contains 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
sips -s format png your_pdf_file.pdf --out your_png_file.png |
This file contains 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
git log -S "some text" --source --all |
This file contains 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
#http://code.activestate.com/recipes/81188-binary-search/ | |
def binary_search(seq, t): | |
min = 0 | |
max = len(seq) - 1 | |
while True: | |
if max < min: | |
return -1 | |
m = min + (max - min) // 2 | |
if seq[m] < t: | |
min = m + 1 |
This file contains 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
less -RN <filename> |
OlderNewer