Skip to content

Instantly share code, notes, and snippets.

View ccabanero's full-sized avatar

Clint Cabanero ccabanero

View GitHub Profile
@ccabanero
ccabanero / Sample iOS Unit Tests: Working with a ViewController that presents a UIAlertController
Last active September 4, 2022 20:17
Sample iOS Unit Tests: Working with a ViewController that presents a UIAlertController
func testControllerShowsAlertIfUserLogsInWithEmptyUsernameAndPasswordTextField() {
// mock of LoginViewController
class MockLoginViewController: LoginViewController {
var presentViewControllerTarget: UIViewController?
override func presentViewController(viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)?) {
presentViewControllerTarget = viewControllerToPresent
}
}
@ccabanero
ccabanero / Sample iOS Unit Tests: Testing a Segue is called using a Mock UIViewController
Last active February 7, 2018 16:14
Sample iOS Unit Tests: Testing a Segue is called using a Mock UIViewController
// Sample 1: Calling segue to transition to another ViewController by tapping a UICollectionView cell
func testSUT_CanTransitionToTargetViewController_WhenCollectionViewCellTapped() {
// declare mock
class MockViewController: ViewController {
var segueIdentifier: NSString?
override private func performSegueWithIdentifier(identifier: String, sender: AnyObject?) {
segueIdentifier = identifier
@ccabanero
ccabanero / Sample iOS Unit Tests: Working with a ViewController composed of Custom Views
Last active October 1, 2018 16:02
Sample iOS Unit Tests: Working with a ViewController composed of Custom Views
func testControllerCanPresentSchoolDataWithCustomSchoolView() {
// get target CustomView
let subviews = self.viewControllerUnderTest.scrollView.subviews
var schoolViews = [SchoolView]()
for currentView in subviews {
if(currentView.isKindOfClass(SchoolView)) {
schoolViews.append(currentView as! SchoolView)
}
}
@ccabanero
ccabanero / ios-remove-uitableviewcell-seperatorline-indentation
Created January 15, 2016 20:19
iOS: Remove UITableViewCell separator line indentation
override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
// for removing the leading margin of the tableview cell's separator line (i.e. the separator is drawn across the entire screen)
if (tableView.respondsToSelector("setSeparatorInset:")) {
tableView.separatorInset = UIEdgeInsetsZero
}
if (tableView.respondsToSelector("setLayoutMargins:")) {
tableView.layoutMargins = UIEdgeInsetsZero
}
@ccabanero
ccabanero / how-to-create-a-cocoa-pod
Last active April 1, 2023 04:43
How to Create a Cocoa Pod
Notes for Creating a Cocoa Pod
Pod Version: 0.39.0
OS: OS X El Capitain (10.11.3)
- - - - - - - - - - - - - - - - - - - - - - -
1. Install CocoaPods (https://guides.cocoapods.org/using/getting-started.html)
2. Create Xcode project to author the Pod
@ccabanero
ccabanero / Android-ErrorReporting-Rollbar
Last active February 24, 2016 22:51
Android-ErrorReporting-Rollbar
Sample code for using Rollbar to report run-time exceptions ...
public class ErrorReporter {
public static void initializeErrorLogging(Context context) {
Rollbar.init(context, Configuration.ROLLBAR_CLIENT_SIDE_TOKEN, Configuration.ROLLBAR_DEPLOYMENT_STATUS);
}
/**
@ccabanero
ccabanero / Installing Perfect on Ubuntu 14.04 (2-5-16 10:23 am)
Last active February 25, 2016 21:24
Installing Perfect on Ubuntu 14.04 (2-5-16 10:23 am)
Trying to Install Perfect framework on Ubuntu 14.04 EC2 instance
Target Ubuntu:
AWS AMI Name is Ubuntu Server 14.04 LTS (HVM), SSD Volume Type - ami-9abea4fb
// install dependencies
$ sudo apt-get update
$ sudo apt-get --assume-yes install git clang libicu-dev libssl-dev libevent-dev libsqlite3-dev libsqlite3-dev libcurl4-openssl-dev uuid-dev make
@ccabanero
ccabanero / Installing Perfect on Ubuntu 14.04 (2-25-16 9:37 pm)
Last active April 12, 2016 12:10
Installing Perfect on Ubuntu 14.04 (2-25-16 9:37 pm)
Trying to Install Perfect framework on Ubuntu 14.04 EC2 instance
Target Ubuntu:
AWS AMI Name is Ubuntu Server 14.04 LTS (HVM), SSD Volume Type - ami-9abea4fb
// install dependencies
$ sudo apt-get update
$ sudo apt-get --assume-yes install git clang libicu-dev libssl-dev libevent-dev libsqlite3-dev libsqlite3-dev libcurl4-openssl-dev uuid-dev make
// install swift snapshot
@ccabanero
ccabanero / Google Maps Android API Utility Library
Created March 5, 2016 16:20
For adding the Google Maps Android API Utility Library as a remote binary dependency in your build.gradle file
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.maps.android:android-maps-utils:0.4+'
}
@ccabanero
ccabanero / Class that Implements ClusterItem
Last active March 6, 2016 00:29
Class that Implements ClusterItem
public class PointOfInterest implements ClusterItem {
private LatLng mLatLng;
/**
* For instantiating a new PointOfInterest
* @param latitude The latitude for the point of interest
* @param longitude The longitude for the point of interest
*/
public PointOfInterest(double latitude, double longitude) {