Skip to content

Instantly share code, notes, and snippets.

@taylanpince
taylanpince / gist:2405109
Created April 17, 2012 10:25
ZBar Integration
ZBarReaderViewController *controller = [ZBarReaderViewController new];
[controller setReaderDelegate:self];
[controller.scanner setSymbology:ZBAR_I25 config:ZBAR_CFG_ENABLE to:0];
UIView *overlayView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.frame.size.width, 80.0)];
UILabel *helpLabel = [[UILabel alloc] initWithFrame:CGRectInset(overlayView.bounds, 15.0, 10.0)];
[helpLabel setFont:[UIFont boldSystemFontOfSize:14.0]];
[helpLabel setTextColor:[UIColor whiteColor]];
@taylanpince
taylanpince / gist:2304382
Created April 4, 2012 18:14
Exporting raster bitmap from shape file
RASTERIZE_COLOR_FIELD = "__color__"
RASTERIZE_COLOR = (158, 18, 110, 200)
pixel_size = 0.05
# Open the data source
orig_data_source = ogr.Open(args[0])
# Make a copy of the layer's data source because we'll need to
@taylanpince
taylanpince / gist:1052154
Created June 28, 2011 20:43
blogTO Best of Title Shortener
NSString *trimmedTitle = [self.entryTitle stringByReplacingOccurrencesOfString:@"The Best"
withString:@""
options:NSCaseInsensitiveSearch
range:NSMakeRange(0, [self.entryTitle length])];
trimmedTitle = [trimmedTitle stringByReplacingOccurrencesOfString:@"in Toronto"
withString:@""
options:NSCaseInsensitiveSearch
range:NSMakeRange(0, [trimmedTitle length])];
@taylanpince
taylanpince / PLBlocks and Xcode 4 Workaround
Created March 25, 2011 19:40
These symlinks allow Xcode 4 to work with the PLBlocks installer
cd /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/PrivatePlugIns/
sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Plug-ins/GCC\ 4.2\ \(Plausible\ Blocks\ -\ iPhoneOS\).xcplugin
cd /Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/
sudo ln -s /Developer/Library/Xcode/Plug-ins/GCC\ 4.2\ \(Plausible\ Blocks\).xcplugin
@taylanpince
taylanpince / gist:450551
Created June 23, 2010 21:01
Array.indexOf Support for IE
// Issue: IE doesn't support Array.indexOf (!)
// Solution: Use this
if (!Array.indexOf){
Array.prototype.indexOf = function(obj) {
for (var i = 0; i < this.length; i++) {
if (this[i] == obj) {
return i;
}
}
from lxml import etree
OSM_API_URL = "http://api.openstreetmap.org/api/0.6/map?bbox=%s"
def get_streets(bbox):
"""
Makes an OSM API request and parses the streets and their waypoints in the
XML response, returns a list