Skip to content

Instantly share code, notes, and snippets.

View atnan's full-sized avatar

Nathan de Vries atnan

View GitHub Profile
Finding the H.264 format of a Vimeo video:
1. Fetch the clip XML metadata (e.g. "http://vimeo.com/moogaloop/load/clip:5531123")
2. Grab the value of "request_signature" and "request_signature_expires" from the XML
3. Use the URL "http://vimeo.com/moogaloop/play/clip:5531123/REQUEST_SIG/REQUEST_SIG_EXPIRES/?q=hd"
@interface UIView (Debugging)
-(void)inspectWithDepth:(int)depth path:(NSString *)path;
@end
# Checking out
git svn init <svn url> <checkout directory>
git svn fetch
git repack -d
# Working
git checkout -b some-feature
git commit -a -m "Some feature"
# Commiting
dpkg --get-selections > packages.txt
dpkg --set-selections < packages.txt
apt-get dselect-upgrade
def measure_time task_description
beginning = Time.now
yield
puts "Time to #{task_description}: #{Time.now - beginning} seconds"
end
def add a, i
a << i
end
class Job < ActiveRecord::Base
STATUS_READY, STATUS_IN_PROGRESS, STATUS_DONE = 1, 2, 3
def self.fetch(pid)
update_all(
{ :status => STATUS_IN_PROGRESS,
:pid => pid },
{ :status => STATUS_READY },
{ :limit => 1,
#define HEXCOLOR(c) [UIColor colorWithRed:((c>>24)&0xFF)/255.0 \
green:((c>>16)&0xFF)/255.0 \
blue:((c>>8)&0xFF)/255.0 \
alpha:((c)&0xFF)/255.0];
UIColor* myColor = HEXCOLOR(0xff0000);
@atnan
atnan / CameraTestAppDelegate.h
Created June 15, 2009 10:53
Sample use of PLCameraController, with snapshots and video
#import <UIKit/UIKit.h>
@interface CameraTestAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
- (void) cameraControllerReadyStateChanged:(NSNotification*)aNotification;
- (void) cameraController:(id)sender tookPicture:(UIImage*)picture withPreview:(UIImage*)preview jpegData:(NSData*)rawData imageProperties:(struct __CFDictionary*) imageProperties;
//
// SynthesizeSingleton.h
// CocoaWithLove
//
// Created by Matt Gallagher on 20/10/08.
// Copyright 2009 Matt Gallagher. All rights reserved.
//
// Permission is given to use this source code file without charge in any
// project, commercial or otherwise, entirely at your risk, with the condition
// that any redistribution (in part or whole) of source code must retain
#!/usr/bin/env ruby
def rake_silent_tasks
dotcache = "#{File.join(File.expand_path('~'), ".raketabs-#{Dir.pwd.hash}")}"
if File.exists?(dotcache)
Marshal.load(File.read(dotcache))
else
require 'rubygems'
require 'rake'
load 'Rakefile'