Skip to content

Instantly share code, notes, and snippets.

View sadatrahman's full-sized avatar

Sadat Rahman sadatrahman

  • Melbourne, Australia
View GitHub Profile
@chrismiles
chrismiles / UIImageView+CMAsyncExtension.m
Created March 6, 2012 02:23
UIImageView (CMAsyncExtension) - async load image from URL
@interface UIImageView (CMAsyncExtension)
- (void)asyncLoadImageFromURL:(NSURL *)imageURL;
@end
@implementation UIImageView (CMAsyncExtension)
- (void)asyncLoadImageFromURL:(NSURL *)imageURL
{
@samnang
samnang / gist:1759336
Created February 7, 2012 11:52
Install Bash version 4 on MacOS X
# Install Bash 4 using homebrew
brew install bash
# Or build it from source...
curl -O http://ftp.gnu.org/gnu/bash/bash-4.2.tar.gz
tar xzf bash-4.2.tar.gz
cd bash-4.2
./configure --prefix=/usr/local/bin && make && sudo make install
# Add the new shell to the list of legit shells
@benjaminpearson
benjaminpearson / gist:1321051
Created October 27, 2011 22:10
Remove Whitespace in Xcode as a Build Phase
- IMPORTANT: Using this will kill your undo history
Steps:
- In Xcode > Select your project > "Build Phases" > "Add Build Phase" > "Add Run Script"
- Paste this script:
sed -i '' 's/[[:space:]]*$//' `find . -name *.h -o -name *.m -not \( -name .svn -prune -o -name .git -prune \) -type f`
- Now whitespace will be removed from .h and .m files on build
- Only problem, doesn't work if path contains a space.... any ideas?
@cppforlife
cppforlife / gist:1269501
Created October 7, 2011 05:09
objective-c debugging env variables
[schwa@ungoliant] ~$ export OBJC_HELP=1
[schwa@ungoliant] ~$ /Applications/Safari.app/Contents/MacOS/Safari
objc[10559]: Objective-C runtime debugging. Set variable=YES to enable.
objc[10559]: OBJC_HELP: describe available environment variables
objc[10559]: OBJC_PRINT_OPTIONS: list which options are set
objc[10559]: OBJC_PRINT_IMAGES: log image and library names as they are loaded
objc[10559]: OBJC_PRINT_LOAD_METHODS: log calls to class and category +load methods
objc[10559]: OBJC_PRINT_INITIALIZE_METHODS: log calls to class +initialize methods
objc[10559]: OBJC_PRINT_RESOLVED_METHODS: log methods created by +resolveClassMethod: and +resolveInstanceMethod:
objc[10559]: OBJC_PRINT_CLASS_SETUP: log progress of class and category setup
@richy486
richy486 / vTag.sh
Created October 4, 2011 02:59
updates your Xcode 4 info.plist with the current git tag as version and commit number
# updates your info.plist with the current git tag as version and commit number
# in that tag as build numer, then ammends the changed file to git
# run this after your normal commit but before you push
#
# this to be placed in the same directory as the xcode project file
# info.plist to be in the path [folder with projectfile]/[project name]/[project name]-Info.plist
# git tags to be in the form of v[number]
#
# Don't forget to do chmod +x ~/whatever/vTag.sh
#
/**
Prevent Xcode 4.1 from using 100% CPU due to a bug while attempting to
connect to a remote iOS device.
# 1. Compile the patch
$ gcc -lobjc -fobjc-gc -framework Foundation -bundle -o _patch NDVXcodeRemoteDevicePatch.m
# 2. Find the PID of Xcode
$ XcodePID=`pidof Xcode`
@nsforge
nsforge / git_commit_all.sh
Created September 26, 2011 07:01
Script to commit all current changes to the current git repo as well as all git submodules
#!/bin/bash
git submodule foreach "git add ."
git submodule foreach "git commit -m \"$1\""
git add .
git commit -m "$1"
@orj
orj / gist:1234366
Created September 22, 2011 08:46
A macro to declare a variable number of Objective-C properties in one statement.
#define CAT(a, b) _PRIMITIVE_CAT(a, b)
#define _PRIMITIVE_CAT(a, b) a##b
#define N_ARGS(...) N_ARGS_1(__VA_ARGS__, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
#define N_ARGS_1(...) N_ARGS_2(__VA_ARGS__)
#define N_ARGS_2(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, n, ...) n
#define PROPERTY(policy, ...) CAT(_PROPERTY_, N_ARGS(__VA_ARGS__))(policy, __VA_ARGS__)
#define PROPERTY_STRONG(...) PROPERTY(retain, __VA_ARGS__)
#define PROPERTY_WEAK(...) PROPERTY(assign, __VA_ARGS__)
@chrismiles
chrismiles / ModelUtil.h
Created June 22, 2011 08:28
My Core Data model helper functions
//
// ModelUtil.h
//
// Copyright 2011 Chris Miles. All rights reserved.
//
// 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
@pk
pk / ExampleTest.m
Created June 21, 2011 15:00
Using method swizzling and blocks to test Class methods in Objective-C.
#import "SenTestCase+MethodSwizzling.m"
@interface ExampleTest : SenTestCase {}
+ (BOOL)trueMethod;
+ (BOOL)falseMethod;
@end
@implementation ExampleTest
+ (BOOL)trueMethod { return YES; }