Skip to content

Instantly share code, notes, and snippets.

@zachwaugh
zachwaugh / ZWDictionaryOfVariableBindings.m
Last active July 29, 2016 12:39
Experiment to figure out how NSDictionaryOfVariableBindings works, and try to make a more flexible version. This version strips underscores and supports self.* variables, but I'm sure there is a better way to do it.
#import <Foundation/Foundation.h>
// Experimental improvement to NSDictionaryOfVariableBindings where keys are simplified to remove underscores and "self." prefixes
// so you can use the simple version within the VFL string
//
// Example:
//
// [NSLayoutConstraint constraintsWithVisualFormat:@"|-[_foo]-[self.bar]-[baz]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_foo, self.bar, baz)];
// -> this doesn't work, gives an error about "self."
//
@sundevilyang
sundevilyang / Gemfile
Created October 2, 2012 06:09 — forked from zernel/Gemfile
Devise authentication with multiple provider
gem 'devise'
gem 'omniauth'
gem 'omniauth-github'
gem "omniauth-twitter"
gem "omniauth-facebook"
gem "omniauth-google-oauth2"
@zen4ever
zen4ever / gist:2327666
Created April 7, 2012 11:13
Print available video capture formats on iOS
AVCaptureVideoDataOutput *videoOutput = [[AVCaptureVideoDataOutput alloc] init];
NSDictionary *formats = [NSDictionary dictionaryWithObjectsAndKeys:
@"kCVPixelFormatType_1Monochrome", [NSNumber numberWithInt:kCVPixelFormatType_1Monochrome],
@"kCVPixelFormatType_2Indexed", [NSNumber numberWithInt:kCVPixelFormatType_2Indexed],
@"kCVPixelFormatType_4Indexed", [NSNumber numberWithInt:kCVPixelFormatType_4Indexed],
@"kCVPixelFormatType_8Indexed", [NSNumber numberWithInt:kCVPixelFormatType_8Indexed],
@"kCVPixelFormatType_1IndexedGray_WhiteIsZero", [NSNumber numberWithInt:kCVPixelFormatType_1IndexedGray_WhiteIsZero],
@"kCVPixelFormatType_2IndexedGray_WhiteIsZero", [NSNumber numberWithInt:kCVPixelFormatType_2IndexedGray_WhiteIsZero],
@"kCVPixelFormatType_4IndexedGray_WhiteIsZero", [NSNumber numberWithInt:kCVPixelFormatType_4IndexedGray_WhiteIsZero],
@panupan
panupan / Gemfile
Created December 6, 2011 18:44
Sinatra ActiveRecord Mock Server
source 'http://rubygems.org'
gem 'sinatra'
gem 'sinatra-activerecord'
gem 'sqlite3'
gem 'require_all'
@panupan
panupan / s3mirror.sh
Created October 25, 2011 20:34
Mirror all Amazon S3 buckets with daily cron script using s3cmd
#!/bin/bash
BACKUP_DIR='/backups/S3 Mirror/'
BUCKETS=$(s3cmd ls | grep s3 | awk '{ print $3 }')
for i in $BUCKETS; do
CURRENT_DIR=$BACKUP_DIR${i//s3:\/\//}/
echo Mirroring $i to $CURRENT_DIR
mkdir -p "$CURRENT_DIR"
s3cmd sync --verbose --no-check-md5 --recursive --no-delete-removed $i "$CURRENT_DIR"
@panupan
panupan / respondersview.h
Created September 28, 2011 17:51
NSViewController responder chain integration
//
// RespondersView.h
// RespondersView
//
// Created by Panupan Sriautharawong on 9/13/11.
// Copyright 2011 Panupan.com. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@panupan
panupan / VBox.h
Created September 23, 2011 23:18
Cocoa VBox
//
// VBox.h
// VBox
//
// Created by Panupan Sriautharawong on 9/23/11.
// Copyright 2011 Panupan.com. All rights reserved.
//
@interface WILLVBox : NSView {
NSColor *backgroundColor;
@rmoriz
rmoriz / Gemfile
Last active February 7, 2020 12:30
UUID primary keys in Rails 3
# Gemfile
gem 'uuidtools'
Copyright (C) 2011 by Strobe Inc
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
@benlodotcom
benlodotcom / MyAVController.h
Last active February 3, 2016 17:45
A little demo snippet that you can use to access directly the camera video in IOS4
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <CoreVideo/CoreVideo.h>
#import <CoreMedia/CoreMedia.h>
/*!
@class AVController
@author Benjamin Loulier