Skip to content

Instantly share code, notes, and snippets.

View atnan's full-sized avatar

Nathan de Vries atnan

View GitHub Profile
CALayer* layer = someView.layer;
CAKeyframeAnimation* animation;
animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.z"];
animation.duration = 1.0;
animation.cumulative = YES;
animation.repeatCount = 1;
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeForwards;
FB_RequireFeatures(["Connect", "XFBML"], function() {
FB.init(FacebookConfig.api_key, "facebook_crossdomain_comm_channel.html");
});
function facebookRequestPermissionIfNecessary(permission, callback) {
FB.ensureInit(function() {
FB.Facebook.apiClient.users_hasAppPermission(permission, function(result) {
if (result == 0) {
FB.Connect.showPermissionDialog(permission, callback);
} else {
import java.awt.*;
import java.awt.event.*;
public class FullScreen extends java.applet.Applet {
private Label label;
private Window window;
private boolean running;
private int clicks;
private String[] messages = new String[] {
NSURL *appURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.itunes.com/app/%@",
[[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
#import <Foundation/Foundation.h>
int main(void) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSURL* url = [NSURL URLWithString:@"https://twitter.com/"];
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"HEAD"];
NSHTTPURLResponse* response;
#!/bin/sh
################################################################################
#
# renameXcodeProject.sh
#
# author: Monte Ohrt <[email protected]>
# date: Jan 27, 2009
# version: 1.0
#
#!/bin/bash
cat .gitignore | egrep -v "^#|^$" | while read line; do
if [ -n "$line" ]; then
OLD_IFS=$IFS; IFS=""
for ignored_file in $( git ls-files "$line" ); do
git rm --cached "$ignored_file"
done
IFS=$OLD_IFS
fi
- (void)keyboardWillShow:(NSNotification *)notification {
if(nil != self.view.window){
CGRect appFrame = [[UIScreen mainScreen] applicationFrame];
CGRect keyboardBounds = [[[notification userInfo] valueForKey:UIKeyboardBoundsUserInfoKey] CGRectValue];
CGRect searchBounds = [self.searchBar bounds];
CGFloat height = CGRectGetHeight(appFrame) - CGRectGetHeight(keyboardBounds) - CGRectGetHeight(searchBounds);
CGRect visibleBounds = CGRectMake(CGRectGetMinX(appFrame),
CGRectGetMinY(appFrame) + CGRectGetHeight(searchBounds),
CGRectGetWidth(appFrame),
height);
@atnan
atnan / gist:218497
Created October 26, 2009 08:05 — forked from neror/gist:216705
#import <UIKit/UIKit.h>
#import "GTMStackTrace.h"
#ifdef DEBUG
extern BOOL NSDebugEnabled;
extern BOOL NSZombieEnabled;
extern BOOL NSDeallocateZombies;
extern BOOL NSHangOnUncaughtException;
static void exceptionHandler(NSException *exception) {
FTLOG(@"%@", GTMStackTraceFromException(exception));
#!/usr/bin/env ruby
require 'rubygems'
require 'open-uri'
require 'hpricot'
require 'activesupport'
require 'gchart'
# USAGE:
# $ elevation.rb ~/Desktop/windsor-to-wisemans.gpx "Windsor to Wisemans Ferry and Back (a.k.a. 'Pretty Flat')"