Skip to content

Instantly share code, notes, and snippets.

View mbinna's full-sized avatar

Manuel Binna mbinna

View GitHub Profile
@mayoff
mayoff / makeAnimatedGif.m
Created February 16, 2013 23:00
Example of creating an animated GIF on iOS, with no 3rd-party code required. This should also be easy to port to OS X.
#import <UIKit/UIKit.h>
#import <ImageIO/ImageIO.h>
#import <MobileCoreServices/MobileCoreServices.h>
static UIImage *frameImage(CGSize size, CGFloat radians) {
UIGraphicsBeginImageContextWithOptions(size, YES, 1); {
[[UIColor whiteColor] setFill];
UIRectFill(CGRectInfinite);
CGContextRef gc = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(gc, size.width / 2, size.height / 2);
@drance
drance / gist:4546014
Created January 16, 2013 09:57
Workaround to vanilla UICollectionView+UICollectionViewFlowLayout using non-integral origins, leading to blurry cells.
@implementation BHSCollectionViewFlowLayout
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect {
NSArray *allAttrs = [super layoutAttributesForElementsInRect:rect];
for (UICollectionViewLayoutAttributes *attributes in allAttrs) {
attributes.frame = CGRectIntegral(attributes.frame);
}
return allAttrs;
}
@mbinna
mbinna / include-version-info.sh
Last active November 12, 2021 20:59
Include Version Info from Git into Info.plist at build time
Add the script include-version-info.sh into a new run script build phase of your application target. The build phase
should be located after the build phase "Copy Bundle Resources".
@rsobik
rsobik / update_bundle_version.sh
Last active October 12, 2015 16:27
Update CFBundleVersion
# Update the CFBundleVersion in the generated Info.plist using the count of all commits
# Use Xcode's copy of the Git binary
GIT=`xcrun -find git`
# Use the commit count as CFBundleVersion
GIT_COMMIT_COUNT=`${GIT} rev-list --all | wc -l | tr -d ' '`
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${GIT_COMMIT_COUNT}" "${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${GIT_COMMIT_COUNT}" "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Info.plist"
@rsobik
rsobik / update_bundle_short_version_string.sh
Created November 11, 2012 11:00
Update CFBundleShortVersionString String
# Use Xcode's copy of the Git binary
GIT=`xcrun -find git`
## Use the last annotated tag as CFBundleShortVersionString
GIT_TAG=`${GIT} describe --tags`
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${GIT_TAG}" "${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}"
@steipete
steipete / gist:3713233
Created September 13, 2012 09:39
I often use dispatch queues for locking, and this function just makes life SO MUCH EASIER. Accidental deadlocks in more complex code paths are a PITA otherwise. But Apple deprecated dispatch_get_current_queue with iOS6?
nline void pspdf_dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_block_t block) {
dispatch_get_current_queue() == queue ? block() : dispatch_sync(queue, block);
}
@jpinnix
jpinnix / gist:3186304
Created July 27, 2012 05:25
Installing Ruby 1.8.7-p358 with rbenv on Mountain Lion
Follow the instructions here: The Hitchhiker's Guide to Riding a
Mountain Lion http://j.mp/Qm5UJD, including installing XQuartz.
After installing XQuartz set the correct path to the X11 library to
install Ruby 1.8.7-p358 with rbenv:
export CPPFLAGS=-I/opt/X11/include
then let the compiler know where gcc-4.2 is:
@ljanzik
ljanzik / MySegueWithCustomAnimation.h
Created May 30, 2012 09:54
Implement Custom Segue To Use Own Animation
#import <UIKit/UIKit.h>
@interface MySegueWithCustomAnimation : UIStoryboardSegue
@end
@bjhomer
bjhomer / 0_explanation.md
Created April 23, 2012 19:32
Putting "*.m diff=objc" in <repo_root>/.gitattributes

Running echo "*.m diff=objc" >> .gitattributes in a git repo tells git to use the obj-c diff algorithm when running git diff. For the most part, this isn't much different from the standard diff algorithm. However, it adds one key benefit.

In a unified git diff, added lines are prefixed with a +, and removed lines are prefixed with a -. Unchanged lines are provided for context, and have no prefix. As added context, though, unified diffs have a @@-prefixed line at the beginning of each hunk. Minimally, the @@ lines specify which lines in the file are being changed. It can also contain a label, if git can determine an appropriate label for that section of code.

By default, the label on a hunk context line is the name of the enclosing C function. That works great for C-ish code, but completely misses Obj-C method signatures. As a result, when diffing Obj-C files, the context label is either empty, or falls back to the last C-ish declaration it could find. This is usually entirely useless.

Adding

@skeeet
skeeet / xcode_ramdisk.sh
Created April 12, 2012 13:35 — forked from MaximKeegan/xcode_ramdisk.sh
Create a RAM disk for using with XCode
#!/bin/sh
# Create a RAM disk with same perms as mountpoint
# Script based on http://itux.idev.pro/2012/04/iservice-speed-up-your-xcode-%D0%BD%D0%B5%D0%BA%D0%BE%D1%82%D0%BE%D1%80%D1%8B%D0%B5-%D1%81%D0%BF%D0%BE%D1%81%D0%BE%D0%B1%D1%8B/ with some additions
# Usage: sudo ./xcode_ramdisk.sh start
USERNAME=$(logname)
TMP_DIR="/private/tmp"
RUN_DIR="/var/run"
SYS_CACHES_DIR="/Library/Caches"