Moved these to a full repo
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
function list (vars, context) { | |
if (typeof(context) === 'undefined') { | |
context = window; | |
} | |
return function (item, i) { | |
context[vars[i]] = item; | |
}; | |
} | |
[1,2,3].each(list(['foo','bar','baz'])) |
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
<?php | |
// Encode an array to a CSV delimited row using PHP's memory output buffer | |
// http://php.net/manual/en/wrappers.php.php | |
function array_to_csv_line($data_array) { | |
$temp_mem = fopen("php://temp", 'r+'); | |
fputcsv($temp_mem, $data_array); | |
rewind($temp_mem); | |
$data_csv = trim(stream_get_contents($temp_mem)); | |
return $data_csv; |
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
""" | |
Given a list of scores, returns the index of one of those items at random, | |
biased towards the items with the highest scores. | |
e.g. random_index_with_bias([84, 62, 61, 67, 45]) | |
To show it works, run it 1,000,000 times: | |
>>> scores = {} | |
>>> for i in range(1000000): |
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
#!/usr/bin/env python | |
""" | |
Fetch all a user's Last.fm scrobbles by paging through their recent tracks | |
Usage: ./fetch.py <username> [<start_page> [<end_page>]] | |
Be aware: You may end up with duplicated data if the user is scrobbling | |
when you fetch for tracks. Make sure you check for dupes when you process | |
the XML later | |
""" |
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 d = document, | |
w = window, | |
k = d.getSelection, | |
x = d.selection, | |
ws = w.getSelection, | |
s = (ws ? ws() : (k) ? k() : (x ? x.createRange().text : 0)), | |
l = d.location, | |
e = encodeURIComponent; | |
var tweetId = /\d+$/.exec(l)[0]; |
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
<?php | |
@$data = file_get_contents($_GET['image']); | |
if (!$data) { | |
header("HTTP/1.1 400 Bad Request"); | |
exit; | |
} | |
@$img = imagecreatefromstring($data); | |
if (!$img) { | |
header("HTTP/1.1 400 Bad Request"); |
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
# Not really git related, this is for ls colors, put in e.g. ~/.bash_login | |
export CLICOLOR="true" | |
export LSCOLORS="DxfxexdxCxegedabagacad" |
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
// ==UserScript== | |
// User script to turn off the "I love circles!!!11!" option on This Is My Jam by default. | |
// Click raw to install in Chrome | |
// Should work with Greasemonkey and the like in other browsers | |
// @match http://thisismyjam.com/jam/meta | |
// @match http://www.thisismyjam.com/jam/meta | |
// ==/UserScript== | |
document.getElementById('circle').click() |
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
gpu() { | |
stashlist="$(git stash list)" | |
if [ "$stashlist" ]; then | |
echo "Already stashed changes" | |
echo $stashlist | |
return 1; | |
fi | |
git stash && git pull && git stash pop; | |
} |
OlderNewer