Skip to content

Instantly share code, notes, and snippets.

View fjcaetano's full-sized avatar
⌨️

Flávio Caetano fjcaetano

⌨️
View GitHub Profile
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 {
var randomNumbers = [42, 12, 88, 62, 63, 56, 1, 77, 88, 97, 97, 20, 45, 91, 62, 2, 15, 31, 59, 5]
func partition(v: Int[], left: Int, right: Int) -> Int {
var i = left
for j in (left + 1)..(right + 1) {
if v[j] < v[left] {
i += 1
(v[i], v[j]) = (v[j], v[i])
}
}
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 / 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.
@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 / 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 / patterns
Last active February 10, 2020 20:19
Some patterns to use with NSStringMask
These are a few patterns commonly used.
1 - Digits only: (\\d+)
2 - Names without special characters: ([A-Za-z\\s]+)
3 - Email: (([\\w\\.\\-]*?@)([\\w\\.\\-]+)(\\.[a-z]{2,4}) # Incompatible with versions previous to 1.1.2 of NSStringMask
4 - Dates: (\\d{2})/(\\d{2})/(\\d{4})
5 - SSN: (\\d{3})-(\\d{2})-(\\d{3})
6 - Telephone: (\\d{3})-(\\d{3})-(\\d{4})
Brasil:
@fjcaetano
fjcaetano / .gitignore-global
Created November 14, 2012 00:15
Global .gitignore file focused on PyCharm
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
*.pyc