Skip to content

Instantly share code, notes, and snippets.

View lxcid's full-sized avatar

Stan Chang Khin Boon lxcid

View GitHub Profile
@lxcid
lxcid / AviarySDK-4.2.0.podspec
Last active August 29, 2015 14:04
AviarySDK 4.2.0 Pod Specs.
Pod::Spec.new do |s|
s.name = 'AviarySDK'
s.version = '4.2.0'
s.summary = "Aviary's photo editing SDK for iOS."
s.homepage = 'http://developers.aviary.com/docs/ios'
s.license = {
:type => 'Commercial',
:text => <<-LICENSE
Copyright (c) 2014 Aviary, Inc. All rights reserved.
LICENSE
@lxcid
lxcid / LXOperatingHours.h
Created January 17, 2012 02:02
LXOperatingHours
#import <Foundation/Foundation.h>
enum {
LXMonday = 1 << 0,
LXTuesday = 1 << 1,
LXWednesday = 1 << 2,
LXThursday = 1 << 3,
LXFriday = 1 << 4,
LXSaturday = 1 << 5,
LXSunday = 1 << 6,
@lxcid
lxcid / gist:2586763
Last active October 4, 2015 05:38
Call resume() to stop the block from exercising the run loop and break out of the loop/block. Failure to call resume() will cause the test to hang indefinitely. This is useful to testing asynchronous actions like AFNetworking operations. See https://gist.github.com/2215212 With some reference from https://github.com/icanzilb/MTTestSemaphore, I w…
typedef void (^LXSResumeBlock)(void);
typedef void (^LXSRunLoopBlock)(LXSResumeBlock resume);
// Call resume() to stop the block from exercising the run loop and break out of the loop/block.
// Failure to call resume() will cause the test to hang indefinitely.
// This is useful to testing asynchronous actions like AFNetworking operations. See https://gist.github.com/2215212
// With some reference from https://github.com/icanzilb/MTTestSemaphore, I was able to simplify this method.
inline void LXS_exercisesRunLoopInBlock(LXSRunLoopBlock block) {
__block BOOL keepRunning = YES;
block(^{ keepRunning = NO; });
while (keepRunning && [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.03]]) {
@lxcid
lxcid / Patch01.m
Created June 20, 2012 06:56
IRGeoInterceptor patch.
- (IRGeoInterceptor *)interceptorWithDelegate:(id<MKMapViewDelegate>)theDelegate {
if (_interceptor == nil) {
_interceptor = [[IRGeoInterceptor alloc] init];
_interceptor.middleMan = self;
_interceptor.receiver = theDelegate;
[super setDelegate:(id<MKMapViewDelegate>)_interceptor];
}
return _interceptor;
@lxcid
lxcid / ProxyView.m
Created June 26, 2012 15:16
Hacking view... like a noob...
#import "ProxyView.h"
@implementation ProxyView
@synthesize targetView = _targetView;
- (UIView *)hitTest:(CGPoint)thePoint withEvent:(UIEvent *)theEvent {
return [self.targetView hitTest:thePoint withEvent:theEvent];
}
@lxcid
lxcid / purchase-info.txt
Created December 1, 2012 05:26
Comparing decoded `purchase-info` from `SKPaymentTransaction` to `receipt` from Apple's receipt validation response.
# The decoded `purchase-info` from `SKPaymentTransaction`:
{
bid = "com.example.app";
bvrs = 7;
"item-id" = 580191698;
"original-purchase-date" = "2012-11-27 15:26:42 Etc/GMT";
"original-purchase-date-ms" = 1354030002000;
"original-purchase-date-pst" = "2012-11-27 07:26:42 America/Los_Angeles";
"original-transaction-id" = 1000000059318468;
@lxcid
lxcid / deploy.rb
Created January 18, 2013 15:54
Replaces deploy:assets:precompile task to do assets precompilation locally.
# Base on http://stackoverflow.com/a/12839484/379604 and https://github.com/capistrano/capistrano/blob/master/lib/capistrano/recipes/deploy/assets.rb
namespace :deploy do
namespace :assets do
desc <<-DESC
Run the asset precompilation rake task locally. You can specify the \
full path to the rake executable by setting the rake variable. You \
can also specify additional environment variables to pass to rake via \
the asset_env variable. The defaults are:
set :rake, "rake"
- (void)modifySelectedString: (NSDictionary *)theAttribute {
NSString *mainString = [self.mainStringLabel.attributedText string];
NSString *queryString = [self selectStringFromMainStringLabelViaStepper];
NSRange selectedStringRange = NSMakeRange(0, mainString.length);
while (selectedStringRange.location != NSNotFound) {
NSRange selectedStringRange = [mainString rangeOfString:queryString options:0 range:selectedStringRange];
if (selectedStringRange.location != NSNotFound) {
[self addAttributeWithRangeToSelectedString:theAttribute range:selectedStringRange];
@lxcid
lxcid / test_with_ios-sim.sh
Created April 27, 2013 13:02
Xcode's Build Phases' Run Script: Test with ios-sim.
if [ "$RUN_UNIT_TEST_WITH_IOS_SIM" = "YES" ]; then
test_bundle_path="$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.$WRAPPER_EXTENSION"
ios-sim launch "$(dirname "$TEST_HOST")" --setenv DYLD_INSERT_LIBRARIES=/../../Library/PrivateFrameworks/IDEBundleInjection.framework/IDEBundleInjection --setenv XCInjectBundle="$test_bundle_path" --setenv XCInjectBundleInto="$TEST_HOST" --args -SenTest All "$test_bundle_path" 2> log.txt
echo "Finished running tests with ios-sim"
failure=$(grep -q "with 0 failures" log.txt; echo $?)
if [ $failure != 0 ]; then
printf "\n"
grep --color=always "error:" log.txt
fi
rm log.txt
@lxcid
lxcid / test_with_uiautomation.sh
Created April 27, 2013 13:11
Xcode's Build Phases' Run Script: Test with UIAutomation.
sudo dscl . append /Groups/_developer GroupMembership $USER
sudo DevToolsSecurity -enable
sudo -S su $USER -l -c "instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate \"$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.$WRAPPER_EXTENSION\" -e UIASCRIPT \"$PROJECT_DIR/UIAutomations/uia_tap_on_unit_conversion.js\" -e UIARESULTSPATH \"$PROJECT_DIR/logs/\""