Skip to content

Instantly share code, notes, and snippets.

View Pretz's full-sized avatar

Alex Pretzlav Pretz

View GitHub Profile
@Pretz
Pretz / gist:1317874
Created October 26, 2011 21:09
JSON Perf on iPhone 4S
2011-10-26 16:08:32.778 JSONPerfTest[2436:707] SBJSON-twitter_public.json 2.083
2011-10-26 16:08:33.919 JSONPerfTest[2436:707] YAJL-twitter_public.json 1.136
2011-10-26 16:08:36.969 JSONPerfTest[2436:707] TouchJSON-twitter_public.json 3.047
2011-10-26 16:08:37.737 JSONPerfTest[2436:707] JSONKit-twitter_public.json 0.765
2011-10-26 16:08:38.685 JSONPerfTest[2436:707] NextiveJson-twitter_public.json 0.946
2011-10-26 16:08:39.493 JSONPerfTest[2436:707] NSJSONSerialization-twitter_public.json 0.806
2011-10-26 16:08:43.699 JSONPerfTest[2436:707] SBJSON-lastfm.json 4.201
2011-10-26 16:08:45.641 JSONPerfTest[2436:707] YAJL-lastfm.json 1.940
2011-10-26 16:08:50.868 JSONPerfTest[2436:707] TouchJSON-lastfm.json 5.224
@Pretz
Pretz / gist:1318141
Created October 26, 2011 22:15
JSON Performance on iPhone 3GS iOS 5
2011-10-26 17:11:01.966 JSONPerfTest[195:707] SBJSON-twitter_public.json 19.425
2011-10-26 17:11:09.877 JSONPerfTest[195:707] YAJL-twitter_public.json 7.879
2011-10-26 17:11:20.179 JSONPerfTest[195:707] TouchJSON-twitter_public.json 10.275
2011-10-26 17:11:22.405 JSONPerfTest[195:707] JSONKit-twitter_public.json 2.204
2011-10-26 17:11:25.267 JSONPerfTest[195:707] NextiveJson-twitter_public.json 2.839
2011-10-26 17:11:27.291 JSONPerfTest[195:707] NSJSONSerialization-twitter_public.json 1.990
2011-10-26 17:11:39.849 JSONPerfTest[195:707] SBJSON-lastfm.json 12.504
2011-10-26 17:11:45.418 JSONPerfTest[195:707] YAJL-lastfm.json 5.546
2011-10-26 17:11:59.969 JSONPerfTest[195:707] TouchJSON-lastfm.json 14.524
@Pretz
Pretz / gist:1338731
Created November 4, 2011 05:37
NSURL oddness
(gdb) po [[NSURL alloc] initWithScheme:@"https" host:@"localhost:8000" path:@"/xauth_login/"]
https://localhost:8000/xauth_login///
(gdb) po [NSURL URLWithString:@"https://localhost:8000/xauth_login/"]
https://localhost:8000/xauth_login/
@Pretz
Pretz / RoundedImageView.java
Created January 10, 2012 02:47
Andround Rounded Image View
package com.yelp.android.ui.widgets;
import com.yelp.android.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
@Pretz
Pretz / generate.py
Created February 8, 2012 21:04
CSV to WAV: Needed a way to convert a list of numbers in a CSV file to a wave audio file. Go python.
#!/usr/bin/python
import wave
import numpy
import struct
import sys
import csv
from scikits.samplerate import resample
def write_wav(data, filename, framerate, amplitude):
@Pretz
Pretz / controller-sample.java
Last active December 11, 2015 06:58
samples for a blog post on LibGDX programming targeting OUYA
public class Cursor {
public static float DEFAULT_VELOCITY = 500f;
private final Vector2 position;
public final Vector2 velocity;
public Cursor() {
position = new Vector2(0, 0);
velocity = new Vector2(0, 0);
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.0.4/plexus-utils-1.0.4.jar (160 KB at 125.9 KB/sec)
[INFO] Compiling 11 source files to /home/alex/apk2gold/jd-cli/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 27.568s
[INFO] Finished at: Fri Jan 25 15:58:50 CST 2013
[INFO] Final Memory: 10M/115M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project jd-core-java: Compilation failure: Compilation failure:
collisionMatrix = new boolean[160][90];
Pixmap backgroundMap = new Pixmap(Gdx.files.internal("data/warehouse-map.png"));
for (int y = 0; y < 90; y++) {
for (int x = 0; x < 160; x++) {
// Get the pixel, shifting off the alpha value
int pixel = backgroundMap.getPixel(x, y) >>> 8;
if (pixel == 0x000000) {
// true means impassible, also invert y to match our coordinate system
collisionMatrix[x][90 - y] = true;
}
@Pretz
Pretz / genstrings
Created March 18, 2013 16:38
Apparently Apple doesn't understand how command line arguments work
alex@alex-silvercar:~/dev/mobile/driverapp/driverapp $ genstrings --help
alex@alex-silvercar:~/dev/mobile/driverapp/driverapp $ genstrings -h
alex@alex-silvercar:~/dev/mobile/driverapp/driverapp $ genstrings -help
alex@alex-silvercar:~/dev/mobile/driverapp/driverapp $ genstrings
Usage: genstrings [OPTION] file1.[mc] ... filen.[mc]
Options
-j sets the input language to Java.
-a append output to the old strings files.
-s substring substitute 'substring' for NSLocalizedString.
@Pretz
Pretz / comprehension.m
Last active December 20, 2015 05:59
draft of a dictionary comprehension idea for obj-c: generating dictionaries over collections using simple-ish block syntax.
- (NSDictionary *)dictionaryOfPeople:(NSArray *)people {
return [people dictionaryViaEnumeration:^(Person *person, id *key, id *value) {
*key = person.identifier;
*value = person.name;
}];
}
////////////////////
typedef void (^TransformBlock)(id obj, id *key, id *value);