Skip to content

Instantly share code, notes, and snippets.

View Pretz's full-sized avatar

Alex Pretzlav Pretz

View GitHub Profile
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
#!/usr/bin/env ruby -wKU
require 'net/http'
require 'uri'
### SEE http://www.kloonigames.com/blog/games/4mins33secs
STDOUT.sync = true; token = rand(28000); time = 0
uri_root = "http://www.kloonigames.com/nordicjam2009/"
start = URI.parse(uri_root + "new_game.php?v=#{token}");
whois = URI.parse(uri_root + "whois.txt");
#!/opt/local/bin/perl -w
# Scrapes the AirBears logon page for interesting variables and authenticates
# you with a given SID and password. Should work with minor modifications
# for other Vernier based systems.
#
# Licensed under the WTFPL, see http://sam.zoy.org/wtfpl/
#
# (C) 2006 Joshua Kwan <joshk@ocf.berkeley.edu>
use HTTP::Cookies;
import web
import httplib
urls = ("/(.+?)/?", "http_err")
app = web.application(urls, globals())
class http_err:
def GET(self, err_code):
err_code = int(err_code.split("/")[0])
response = "%d %s" % (err_code, httplib.responses[err_code])
@Pretz
Pretz / trac-tickets-to-gh.py
Created September 21, 2010 03:03 — forked from dittos/trac-tickets-to-gh.py
import trac tickets to github from a mysql trac install
import sys; reload(sys); sys.setdefaultencoding('utf-8')
import MySQLdb
import urllib2
import urllib
import simplejson
login = 'your github login'
token = 'your github API key'
repo = 'username/repo'
@Pretz
Pretz / gist:822036
Created February 11, 2011 07:09
xAuth in Android for Instapaper using Signpost
protected String[] doInBackground(String... credentials) {
String consumer_secret = mActivity.getString(R.string.oauth_consumer_secret);
HttpClient client = new DefaultHttpClient();
HttpPost request = new HttpPost("https://www.instapaper.com/api/1/oauth/access_token");
CommonsHttpOAuthConsumer consumer = new CommonsHttpOAuthConsumer(mActivity.getString(R.string.oauth_consumer_key),
consumer_secret);
List<BasicNameValuePair> params = Arrays.asList(
new BasicNameValuePair("x_auth_username", credentials[0]),
new BasicNameValuePair("x_auth_password", credentials[1]),
new BasicNameValuePair("x_auth_mode", "client_auth"));
@Pretz
Pretz / Business.json
Created April 8, 2011 00:23
Parcelgen description for a Yelp API Business
{
"do_json": true,
"package": "com.yelp.parcelgen",
"props": {
"String": [
"id", "name", "imageUrl", "url", "mobileUrl",
"phone", "displayPhone", "ratingImageUrl",
"ratingImageUrlSmall", "snippetText", "snippetImageUrl"
],
"int": ["reviewCount"],
@Pretz
Pretz / read_http.java
Created April 25, 2011 23:01
WTF Java
int contentLength = 0;
if (request.containsHeader("content-length")) {
contentLength = Integer.parseInt(request.getFirstHeader("content-length").getValue());
}
String bodyString = null;
if (contentLength > 0) {
BasicHttpEntityEnclosingRequest req = new BasicHttpEntityEnclosingRequest(request.getRequestLine());
try {
conn.receiveRequestEntity(req);
@Pretz
Pretz / find-missing.py
Created May 5, 2011 02:36
Find all tracks in an iTunes library xml file that don't exist. Run from your iTunes folder
import re, htmlentitydefs, os.path, urllib
##
# Removes HTML or XML character references and entities from a text string.
# Thank you Fredrik Lundh
# http://effbot.org/zone/re-sub.htm#unescape-html
#
# @param text The HTML (or XML) source text.
# @return The plain text, as a Unicode string, if necessary.
@Pretz
Pretz / gist:1317854
Created October 26, 2011 21:06
JSON Perf in Simulator
2011-10-26 16:04:05.344 JSONPerfTest[27924:10103] SBJSON-twitter_public.json 0.371
2011-10-26 16:04:05.605 JSONPerfTest[27924:10103] YAJL-twitter_public.json 0.259
2011-10-26 16:04:06.076 JSONPerfTest[27924:10103] TouchJSON-twitter_public.json 0.470
2011-10-26 16:04:06.190 JSONPerfTest[27924:10103] JSONKit-twitter_public.json 0.113
2011-10-26 16:04:06.327 JSONPerfTest[27924:10103] NextiveJson-twitter_public.json 0.135
2011-10-26 16:04:06.434 JSONPerfTest[27924:10103] NSJSONSerialization-twitter_public.json 0.106
2011-10-26 16:04:07.093 JSONPerfTest[27924:10103] SBJSON-lastfm.json 0.656
2011-10-26 16:04:07.447 JSONPerfTest[27924:10103] YAJL-lastfm.json 0.354
2011-10-26 16:04:08.275 JSONPerfTest[27924:10103] TouchJSON-lastfm.json 0.827
2011-10-26 16:04:08.444 JSONPerfTest[27924:10103] JSONKit-lastfm.json 0.168