Skip to content

Instantly share code, notes, and snippets.

View atnan's full-sized avatar

Nathan de Vries atnan

View GitHub Profile
- (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);
#!/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
#!/bin/sh
################################################################################
#
# renameXcodeProject.sh
#
# author: Monte Ohrt <[email protected]>
# date: Jan 27, 2009
# version: 1.0
#
#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;
NSURL *appURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.itunes.com/app/%@",
[[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
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[] {
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 {
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;
var ify = function() {
return {
"link": function(t) {
return t.replace(/(^|\s+)(https*\:\/\/\S+)/g, function(m, m1, link) {
return m1.concat('<a href="', link, '">', link.substr(0, 24), 25 < link.length ? '...' : '', '</a>');
});
},
"at": function(t) {
return t.replace(/(^|\s+)\@([a-zA-Z0-9_]{1,15})/g, ‘$1@<a href=”http://twitter.com/$2″>$2</a>’);
},
@implementation NSArray(Filtering)
- (NSArray*)arrayByMappingArrayUsingSelector:(SEL)selector, ... {
NSInvocation* invocation;
va_list arguments;
if (selector && [self lastObject]) {
va_start(arguments, selector);
invocation = [NSInvocation invocationUsingSelector:selector onTarget:[self lastObject] argumentList:arguments];
va_end(arguments);
}