View ReachabilityExample.m
#pragma mark - Reachability | |
/** | |
* This kicks off a check for our website's reachability in the context of needing it to display, or alert the user | |
* of error, just once. That's why we stop the notifier in both reachable and unreachable callback block handlers. | |
* We're not looking for ongoing callbacks through the life of the application; we just want to know the one time. | |
* | |
* This is meant for an iPhone app only, hence, no explicit WWAN setting. | |
* | |
* CREDIT |
View UWFacebookService.m
#import "UWFacebookService.h" | |
@implementation UWFacebookService | |
// Static | |
static const int ddLogLevel = LOG_LEVEL_DEBUG; | |
// Strong | |
@synthesize facebookGraphUser = _facebookGraphUser; |
View automation.sh
#!/bin/bash | |
# automation.sh | |
# Created by @idStar - Sohail Ahmed - September 2, 2012 | |
# This script launches the UIAutomation Instrument targeting a pre-existing iOS Simulator app, from the command line. | |
# Works with Xcode 4.4.1 on Mountain Lion | |
# | |
# Usage: | |
# automation <"App Name.app"> <"testFile.js"> <"base test script path"> <"base iOS Simulator path"> <"results output directory"> | |
# |
View UITableViewCellSublclass.m
- (void)layoutSubviews { | |
[super layoutSubviews]; | |
[self applyEditingModeBackgroundViewPositionCorrections]; | |
} | |
/** | |
When using a backgroundView or selectedBackgroundView on a custom UITableViewCell | |
subclass, iOS7 currently |
View AppDelegate.m
#pragma mark - XCTest Support | |
static BOOL isRunningTests(void) __attribute__((const)); | |
/** | |
We need a mechanism to detect if we have been invoked / are running from a unit test. | |
If we are, we'll want to exit early instead of doing all kinds of view controller setup. | |
This function determines based on the environment, if we're running in a unit test process, | |
such as XCTest. |
View gist:485516741b4e5ea95b7b
# This is what I tried, but I just got crickets after executing it; with nothing happening and no results posted. | |
instruments -t "/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate" "/Users/sohail/Library/Developer/CoreSimulator/Devices/7232A640-A9D2-4626-A2AD-37AFFF706718/data/Containers/Bundle/Application/D07FEC4B-76AD-4844-8362-08E771B81053/MyAppName.app" -e UIASCRIPT "/Users/sohail/source/MyAppName/MyAppNameAutomationTests/TestRunner.js" -e UIARESULTSPATH "Users/sohail/source/MyAppName/MyAppNameAutomationTests/TestResults" |
View MemoryManagementPlayground.swift
// Part 09: Memory Management | |
// Swift 2.0 (Xcode 7 Beta 1) | |
// "Uber" Challenge Exercise from Ray Wenderlich's "Intermediate Swift Series", Part 9. | |
// Series available here: http://www.raywenderlich.com/video-tutorials#swift | |
// Solution created by Sohail Ahmed, twitter: @idStar, blog: http://sohail.io | |
class Conference { | |
var name:String | |
var instructors:[Instructor] = Array<Instructor>() | |
var students:[Student] = Array<Student>() |
View SpreadsheetExportToCSV.scpt
#! /usr/bin/osascript | |
(* | |
--------------------------------------------------------------------------------- | |
Script: SpreadsheetExportToCSV | |
Command-line tool to convert a spreadsheet document to CSV | |
This AppleScript is tested with and compatible with Apple iWork Numbers 3.6, | |
current as at October 23, 2015. |
View findValueForKeyInFile.sh
#!/bin/bash | |
# In this example, we demonstrate how to find the value for a given key, in a particular file, | |
# using the Bash Shell Scripting language. We've setup some primitive functions to provide | |
# some modularity. See near the end for example usage on how you might call this. | |
# | |
# Assumptions: | |
# 1. Stripping leading and trailing whitespace in the value string is desired. | |
# 2. The last occurrence of the key (if there are multiple) is all we care about. |
View String+Extensions.swift
extension String { | |
// Modified from original: https://techvangelist.net/truncate-a-string-in-swift-2-0/ | |
// We respect max character length requested, even if we allow ellipsis. | |
func truncated(toMaxLength length: Int, trailing: String? = "...") -> String { | |
if self.characters.count > length { | |
let trailingText = trailing ?? "" | |
let uptoIndex = length - 1 - trailingText.characters.count | |
return self.substringToIndex(self.startIndex.advancedBy(uptoIndex)) + trailingText | |
} else { |