Skip to content

Instantly share code, notes, and snippets.

View fjcaetano's full-sized avatar
⌨️

Flávio Caetano fjcaetano

⌨️
View GitHub Profile
@fjcaetano
fjcaetano / FJCSingleton.h
Created February 6, 2014 17:28
objc-singleton
//
// FJCSingleton.h
// Singleton
//
// Created by Flávio Caetano on 2/6/14.
// Copyright (c) 2014 flaviocaetano.com. All rights reserved.
//
#import <Foundation/Foundation.h>
@fjcaetano
fjcaetano / gist:9814785
Created March 27, 2014 18:32
Abstract Method Constant
#define kABSTRACT_METHOD @throw [NSException exceptionWithName:NSInternalInconsistencyException reason:[NSString stringWithFormat:@"You must override %@ in a subclass", NSStringFromSelector(_cmd)] userInfo:nil];
This constant should be placed within the project's `.pch` file and be called inside the abstract class' method implementation.
source ~/.bash_profile
hash oclint &> /dev/null
if [ $? -eq 1 ]; then
echo >&2 "oclint not found, analyzing stopped"
exit 1
fi
cd ${TARGET_TEMP_DIR}
@fjcaetano
fjcaetano / version_bumper.sh
Created September 3, 2015 22:33
Xcode Version Bumper
bN=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PROJECT_DIR}/${INFOPLIST_FILE}")
bN=$(($bN + 1))
bN=$(printf "%d" $bN)
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $bN" "${PROJECT_DIR}/${INFOPLIST_FILE}"
var randomNumbers = [42, 12, 88, 62, 63, 56, 1, 77, 88, 97, 97, 20, 45, 91, 62, 2, 15, 31, 59, 5]
randomNumbers
func 💩Sort(arr: Int[]) -> Int[] {
var array = arr.copy()
// Private function to check whether or not the array is sorted
func isSorted (arr: Int[]) -> Bool {
@fjcaetano
fjcaetano / AFNetworkingOperationDelegate.h
Created June 3, 2013 18:53
Return methods definition protocol at the and of a request using AFNetworking.
//
// AFNetworkingOperationDelegate.h
//
// Created by Flávio Caetano on 12/12/12.
// Copyright (c) 2012 FlávioCaetano.com.
//
#import <Foundation/Foundation.h>
#define COMPLETION_BLOCK(delegate) ^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON){[delegate requestDidFinish:request withResponse:response andJSON:JSON];}
@fjcaetano
fjcaetano / changelog.sh
Last active March 3, 2016 16:05
Changelog from previous tag
echo "Printing Changelog"
git log $(git describe --abbrev=0)..HEAD --pretty=oneline --abbrev-commit | envman add --key GIT_CHANGELOG
echo $GIT_CHANGELOG
@fjcaetano
fjcaetano / ChallengeViewController.swift
Created September 27, 2016 21:57
RxSwift error example
//
// ChallengeViewController.swift
// WinninApp
//
// Created by Flávio Caetano on 9/26/16.
// Copyright © 2016 Winnin. All rights reserved.
//
import UIKit
import RxSwift
@fjcaetano
fjcaetano / withPure.tsx
Created December 11, 2018 17:47
Pure React component HOC in Typescript
import React from 'react';
const withPure = <P extends any>(
WrappedComponent: React.ComponentType<P>,
): React.ComponentClass<P> => {
class Purified extends React.PureComponent<P> {
render() {
return <WrappedComponent {...this.props} />;
}
}
@fjcaetano
fjcaetano / build.sh
Created September 3, 2015 21:39
Universal Framework Build Script
#!/bin/sh
exec > /tmp/${PROJECT_NAME}_archive.log 2>&1
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
if [ "true" == ${ALREADYINVOKED:-false} ]
then
echo "RECURSION: Detected, stopping"
else