Skip to content

Instantly share code, notes, and snippets.

Avatar

Joel Bradshaw cincodenada

View GitHub Profile
@cincodenada
cincodenada / UnicodeCSV.py
Created Feb 5, 2011
My basic hack to pull down all of my track history from Last.FM into XML and CSV. It even has resume/top-off functionality.
View UnicodeCSV.py
#Taken from http://docs.python.org/library/csv.html#examples
import csv, codecs, cStringIO
class UTF8Recoder:
"""
Iterator that reads an encoded stream and reencodes the input to UTF-8
"""
def __init__(self, f, encoding):
self.reader = codecs.getreader(encoding)(f)
@cincodenada
cincodenada / xkcdpull.pl
Created Mar 19, 2011
A basic script to pull down xkcd comics and create a TSV index of them.
View xkcdpull.pl
#!/usr/local/bin/perl
#use strict;
#use warnings;
use LWP::Simple;
my $baseurl = 'http://www.xkcd.com/';
my $comicnum = 1;
open (TSV, '>>index.csv');
while($pagecontent = get("$baseurl$comicnum/")) {
$comicnum++;
@cincodenada
cincodenada / xkcdeffect.pl
Created Mar 19, 2011
This is the script I used when writing my blog post about the XKCD effect (http://commacommacrash.com/2009/12/what-i-learned-from-xkcd-effect.html). A base for all my WWW::Mechanize scripts.
View xkcdeffect.pl
#!/usr/bin/perl
use LWP::Simple;
use WWW::Mechanize;
use HTTP::Cookies;
use Term::ReadKey;
use POSIX qw(strftime mktime);
my $interneturl = "http://www.google.com";
my $internet = "Google";
View http_build_url.php
<?php
if (!function_exists('http_build_url'))
{
define('HTTP_URL_REPLACE', 1); // Replace every part of the first URL when there's one of the second URL
define('HTTP_URL_JOIN_PATH', 2); // Join relative paths
define('HTTP_URL_JOIN_QUERY', 4); // Join query strings
define('HTTP_URL_STRIP_USER', 8); // Strip any user authentication information
define('HTTP_URL_STRIP_PASS', 16); // Strip any password authentication information
define('HTTP_URL_STRIP_AUTH', 32); // Strip any authentication information
define('HTTP_URL_STRIP_PORT', 64); // Strip explicit port numbers
@cincodenada
cincodenada / fullcalendar.js
Created Dec 15, 2011
FullCalendar modifications
View fullcalendar.js
/**
* @preserve
* FullCalendar v1.5.1
* http://arshaw.com/fullcalendar/
*
* Use fullcalendar.css for basic styling.
* For event drag & drop, requires jQuery UI draggable.
* For event resizing, requires jQuery UI resizable.
*
* Copyright (c) 2011 Adam Shaw
@cincodenada
cincodenada / splitwav.py
Created Mar 25, 2012
A quick script to split a sample-interlaced wav into two files, used for testing my Honors Project.
View splitwav.py
from sys import argv
import wave
sound = wave.open(argv[1],"r")
one = wave.open("split_one.wav","w")
two = wave.open("split_two.wav","w")
data = sound.readframes(sound.getnframes())
one.setparams(sound.getparams())
@cincodenada
cincodenada / facebook_cscript.js
Created May 23, 2012
Modified script for the "Add Facebook Events to Google Calendar" Chrome extension
View facebook_cscript.js
postpone();
function postpone()
{
init();
window.setTimeout(postpone,500);
}
function init()
{
View gist:3701961
var fileref=document.createElement('script'); fileref.setAttribute("type","text/javascript");fileref.setAttribute("src", 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js'); document.getElementsByTagName("head")[0].appendChild(fileref);
$('div[href^="/files"]').each(function(idx, el) { href = $(el).attr('href'); $(el).replaceWith('<a href="' + href + '">Download</a>') });
@cincodenada
cincodenada / emergent_auth.php
Created Nov 9, 2012
Emergent API Authentication Client
View emergent_auth.php
<?php
ini_set('display_errors','on');
error_reporting(E_ALL);
//This is less than desirable, but we'll figure out restructuring later
$backend_path = '../../../backend/';
require_once($backend_path . 'lib/logger.php');
require_once($backend_path . 'config.php');
$logger = new Logger();
@cincodenada
cincodenada / OrderedFriendsList.js
Created Dec 3, 2012
A snippet of Facebook's javascript, decompressed a bit
View OrderedFriendsList.js
bigPipe.onPageletArrive({
"is_last": true,
"content": {
"pagelet_sidebar": {
"container_id": "u5da1gw108"
}
},
"jsmods": {
"instances": [
["m229365_110", ["ScrollableArea", "m229365_109"],