Skip to content

Instantly share code, notes, and snippets.

@madninja
madninja / inject_version.sh
Created February 26, 2011 19:41
Inject git version info into Info.plist and iOS settings
#!/bin/bash
cd $PROJECT_DIR
BUILD_VERSION=`/usr/local/bin/git rev-parse --short HEAD`
cd "$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.app"
RELEASE_VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" Info.plist)
/usr/libexec/PlistBuddy -c "Set CFBundleVersion $BUILD_VERSION" Info.plist
/usr/libexec/PlistBuddy -c "Set :PreferenceSpecifiers:1:DefaultValue $RELEASE_VERSION ($BUILD_VERSION)" Settings.bundle/Root.plist
@ErikEvenson
ErikEvenson / .gitignore
Created March 12, 2011 22:40
Xcode 4 .gitignore file
.DS_Store
*.swp
*~.nib
build/
*.pbxuser
*.perspective
*.perspectivev3
@rob-brown
rob-brown / RBNetworkActivityIndicatorManager.h
Created July 31, 2011 05:51
A threadsafe network activity indicator manager.
//
// RBNetworkActivityIndicatorManager.h
//
// Copyright (c) 2011 Robert Brown
//
// 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
@markd2
markd2 / log.m
Created June 25, 2012 15:27
QuietLog, and a little demonstration
#import <Foundation/Foundation.h>
// clang -fobjc-arc -Wall -Wformat -Weverything -Wno-format-nonliteral -framework Foundation -o log log.m
// Compiler likes explicit function prototypes prior to first use.
// Add an attribute to get additional checking from the compiler
extern void QuietLog (NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
// !!! The attribute above isn't warning like it should, but NSLog's _is_ working.
// This is NSLog's attribute. I'm currently baffled.
//
// SGDeviceIdentifier.h
// Elements
//
// Created by Justin Williams on 9/28/12.
// Copyright (c) 2012 Second Gear. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <Foundation/Foundation.h>
#import <mach/mach_time.h> // for mach_absolute_time() and friends
// clang -g -fobjc-arc -Weverything -Wno-unused-parameter -framework Foundation -o iteration iteration.m
// Run this by passing arguments on the command line. Run without any
// arguments to see the supported flags. Each time a flag is used causes
// that test to be run and timed, with the time (in seconds) output when
// it finishes. Be careful not to do anything else on your machine (such
// as surfing Redding while getting bored looking at the terminal) otherwise
@kevinbarrett
kevinbarrett / NSFileManager+DoNotBackup.h
Created March 8, 2012 18:02 — forked from tibr/NSFileManager+DoNotBackup.h
Setting the do not backup attribute in different iOS versions
@interface NSFileManager (DoNotBackup)
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL;
@end
------------
Conformances
------------
protocol AbsoluteValuable
Conformances:
Comparable
IntegerLiteralConvertible
SignedNumberType
@mpospese
mpospese / CGRectIntegralScaled.m
Created February 28, 2013 03:34
Pixel aligns rectangles, taking the device's screen scale into account.
CGRect CGRectIntegralScaledEx(CGRect rect, CGFloat scale)
{
return CGRectMake(floorf(rect.origin.x * scale) / scale, floorf(rect.origin.y * scale) / scale, ceilf(rect.size.width * scale) / scale, ceilf(rect.size.height * scale) / scale);
}
CGRect CGRectIntegralScaled(CGRect rect)
{
return CGRectIntegralScaledEx(rect, [[UIScreen mainScreen] scale]);
}
import CoreGraphics
infix operator |> { precedence 50 associativity left }
// MARK: CGPoint
func +(lhs: CGPoint, rhs: CGPoint) -> CGPoint {
return CGPoint(x: lhs.x + rhs.x, y: lhs.y + rhs.y)
}