Skip to content

Instantly share code, notes, and snippets.

View hasanadil's full-sized avatar

hasanadil

  • Portland, Maine, USA
View GitHub Profile
@hasanadil
hasanadil / gist:2f96752bda6f39f96807
Created June 9, 2014 19:55
Terminal log when building map box gl
Hasans-MacBook-Pro-2:mapbox-gl-native hasan$ ls -l
total 80
-rw-r--r-- 1 hasan staff 1311 Jun 9 14:33 LICENSE.md
-rw-r--r-- 1 hasan staff 3480 Jun 9 14:33 Makefile
-rw-r--r-- 1 hasan staff 3960 Jun 9 14:33 README.md
drwxr-xr-x 8 hasan staff 272 Jun 9 14:33 bin
drwxr-xr-x 11 hasan staff 374 Jun 9 14:33 common
-rw-r--r-- 1 hasan staff 1362 Jun 9 14:33 common.gypi
drwxr-xr-x 3 hasan staff 102 Jun 9 14:33 config
-rwxr-xr-x 1 hasan staff 3749 Jun 9 14:33 configure
//
// ASTransitionAnimator.m
// Maps
//
// Created by Hasan on 6/16/14.
// Copyright (c) 2014 AssembleLabs. All rights reserved.
//
#import "ASSlideUpTransitionAnimator.h"
/**
Show prefs on top of the map
*/
-(IBAction) tapShowMenu:(id)sender
{
ASMapPrefsViewController* prefsController = [[ASMapPrefsViewController alloc] initWithMap:self.map];
[prefsController setTransitioningDelegate:self];
[prefsController setModalPresentationStyle:UIModalPresentationCustom];
[self presentViewController:prefsController animated:YES completion:NULL];
//MARK: AVCaptureMetadataOutputObjectsDelegate
func captureOutput(captureOutput: AVCaptureOutput!, didOutputMetadataObjects metadataObjects: [AnyObject]!, fromConnection connection: AVCaptureConnection!) {
for metadata in metadataObjects {
for barcodeType in self.allowedBarcodes {
if metadata.type == barcodeType {
let barcode = (metadata as AVMetadataMachineReadableCodeObject).stringValue as String?
self.session.stopRunning()
if self.delegate != nil {
self.delegate!.didScanBarcode(barcode!)
let allowedBarcodes = [AVMetadataObjectTypeUPCECode,
AVMetadataObjectTypeCode39Code,
AVMetadataObjectTypeCode39Mod43Code,
AVMetadataObjectTypeEAN13Code,
AVMetadataObjectTypeEAN8Code,
AVMetadataObjectTypeCode93Code,
AVMetadataObjectTypeCode128Code,
AVMetadataObjectTypePDF417Code,
AVMetadataObjectTypeQRCode,
AVMetadataObjectTypeAztecCode
let camera = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo)
var error : NSError? = nil
let cameraInput : AVCaptureDeviceInput? = AVCaptureDeviceInput.deviceInputWithDevice(camera, error: &error) as? AVCaptureDeviceInput
self.session.addInput(cameraInput)
if error != nil || cameraInput == nil {
//Awesome error handling :D
println(error!.localizedDescription)
}
else {
class 💩💩💩💩 {
func 💩💩💩(😎: Int, 🐯: Int) -> Int {
return 😎 + 🐯;
}
}
let 🐔 = 3;
let 😥 = 🐔 + 2;
let 💩 = 💩💩💩💩();
print(💩.💩💩💩(🐔, 🐯:😥));
-(void) pixelsFromImage:(NSImage*)image
withCompletion:(void(^)(UInt32 *pixels, NSUInteger pixelCount))completion {
//Extract pixels from the image in a 1D array
CFDataRef inputData = (__bridge CFDataRef)[image TIFFRepresentation];
CGImageSourceRef inputSource = CGImageSourceCreateWithData(inputData, NULL);
CGImageRef inputCGImage = CGImageSourceCreateImageAtIndex(inputSource, 0, NULL);
NSUInteger width = CGImageGetWidth(inputCGImage);
NSUInteger height = CGImageGetHeight(inputCGImage);
NSUInteger numberOfPixels = height * width;
-(void) fetchDominantColorFromImage:(NSImage*)image withCompletion:(void(^)(NSColor *color, NSTimeInterval processingTime))completion {
...
__weak typeof(self) weakMe = self;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
[weakMe pixelsFromImage:image withCompletion:^(UInt32 *pixels, NSUInteger pixelCount) {
....
//Divide up the work among workers
NSUInteger numberOfWorkers = 4;
NSUInteger pixelsPerWorker = pixelCount/numberOfWorkers;
for (NSUInteger worker = 0; worker < numberOfWorkers; worker++) {
//Submit work blocks to be executed concurrently
dispatch_async(weakMe.concurrentQueue, ^{
//Add the colors result to a trie data strucuture whose leaf is the counter, O(1) baby