Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Alex Pretzlav Pretz

🎯
Focusing
View GitHub Profile
View gist:70533
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
View 433.rb
#!/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");
View airbears_auth.pl
#!/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;
View simulate_errorcodes.py
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 Sep 21, 2010 — forked from dittos/trac-tickets-to-gh.py
import trac tickets to github from a mysql trac install
View trac-tickets-to-gh.py
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 Feb 11, 2011
xAuth in Android for Instapaper using Signpost
View gist:822036
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 Apr 8, 2011
Parcelgen description for a Yelp API Business
View Business.json
{
"do_json": true,
"package": "com.yelp.parcelgen",
"props": {
"String": [
"id", "name", "imageUrl", "url", "mobileUrl",
"phone", "displayPhone", "ratingImageUrl",
"ratingImageUrlSmall", "snippetText", "snippetImageUrl"
],
"int": ["reviewCount"],
View read_http.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
Find all tracks in an iTunes library xml file that don't exist. Run from your iTunes folder
View find-missing.py
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 Oct 26, 2011
JSON Perf in Simulator
View gist:1317854
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