Skip to content

Instantly share code, notes, and snippets.

View sadatrahman's full-sized avatar

Sadat Rahman sadatrahman

  • Melbourne, Australia
View GitHub Profile
@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]);
}
@heardrwt
heardrwt / NSBundle+RHLaunchAtLoginAdditions.m
Last active December 13, 2015 21:19
RHLaunchAtLoginAdditions
This has moved. See https://github.com/heardrwt/RHAdditions/blob/master/RHAdditions/NSBundle+RHLaunchAtLoginAdditions.m
@sync
sync / run-tests
Created January 25, 2013 04:14
Teamcity ios-sim integration
if ENV['SL_RUN_UNIT_TESTS'] then
launcher_path = File.join(ENV['SRCROOT'], "../../bin", "ios-sim")
test_bundle_path= File.join(ENV['BUILT_PRODUCTS_DIR'], "#{ENV['PRODUCT_NAME']}.#{ENV['WRAPPER_EXTENSION']}")
environment = {
'DYLD_INSERT_LIBRARIES' => "/../../Library/PrivateFrameworks/IDEBundleInjection.framework/IDEBundleInjection",
'XCInjectBundle' => test_bundle_path,
'XCInjectBundleInto' => ENV["TEST_HOST"]
}
@jessedc
jessedc / php_on_osx.mdown
Last active September 28, 2017 22:13
PHP setup instructions OSX 1.8 Mountain Lion

Setting up PHP on Mountain Lion from scratch

Editing text files from the command line is made easier with TextMate with it's command line extension mate OR Sublime text2 with command line extensions. However the built in nano text editor is easy to use as well.

Some guidance gleaned form from coolestguyplanettech.com

Change permissions on /Library/WebServer/Documents so all users can write to it

sudo chmod -R o+w /Library/WebServer/Documents
@tonyarnold
tonyarnold / NSUserDefaultsObjectSubscripting.h
Created July 29, 2012 07:51
Add simple object subscripting to NSUserDefaults
//
// NSUserDefaults+ObjectSubscripting.h
//
// Created by Tony Arnold on 29/07/12.
// Copyright (c) 2012 The CocoaBots. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSUserDefaults (ObjectSubscripting)
@baz
baz / gist:3073573
Created July 9, 2012 00:38
PPI of iOS device
float screenResolution() {
struct utsname systemInfo;
uname(&systemInfo);
char *name = systemInfo.machine;
float ppi;
if ((strstr(name, "iPod") != NULL) && (strstr(name, "iPod4") == NULL)) {
// older ipod touches
ppi = 163;
} else if ((strstr(name, "iPhone") != NULL) && (strstr(name, "iPhone3") == NULL)) {
@jessedc
jessedc / ObsidianCode.dvtcolortheme
Last active April 20, 2016 09:22 — forked from subdigital/ObsidianCode.dvtcolortheme
Obsidian Code Theme for Xcode 4
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0 0 0 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>Menlo-Bold - 11.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>0 0 0 1</string>
@barraponto
barraponto / git-submodule-rm.sh
Created April 25, 2012 16:36
git submodule-rm
#!/bin/bash
function actual_path() {
if [ [ -z "$1" ] -a [ -d $1 ] ]; then
echo $(cd $1 && test `pwd` = `pwd -P`)
return 0
else
return 1
fi
}
@0xced
0xced / NSString.m
Created April 1, 2012 12:24
Reverse-engineered implementation of -[NSString isEqual:] and -[NSString isEqualToString:]
/*
* Most NSString instances will actually be __NSCFString instances, so here are both NSString and __NSCFString implementations.
* If you know how to create an NSString instance whose class is actually NSString please let me know.
* Other possible concrete subclasses of NSString are: NSConstantString, __NSCFConstantString, NSPathStore2, NSSimpleCString and __NSLocalizedString.
*/
// CoreFoundation.framework 635.19.0 (Mac OS X 10.7.3)
@implementation NSObject
- (BOOL) isNSString__
@tonyarnold
tonyarnold / gist:2010649
Created March 10, 2012 07:22
Exhaustively check if an Objective-C object is "empty"
static inline BOOL CBIsEmpty(id obj) {
return obj == nil
|| (NSNull *)obj == [NSNull null]
|| ([obj respondsToSelector:@selector(length)] && [obj length] == 0)
|| ([obj respondsToSelector:@selector(count)] && [obj count] == 0);
}