Skip to content

Instantly share code, notes, and snippets.

View fel-cesar's full-sized avatar

Felipe Cesar fel-cesar

View GitHub Profile
@fel-cesar
fel-cesar / fix_commit_date.sh
Last active July 20, 2017 18:44
This gist is for fixing past commits date, be careful because all the subsequent hashes will be also changed. ALWAYS make backup before doing so
git filter-branch --env-filter \
'if [ $GIT_COMMIT = <COMMIT_HASH> ]
then
export GIT_AUTHOR_DATE=“Mon Jun 19 21:20:50 2017 -0300"
export GIT_COMMITTER_DATE="<CHANGE DATE ON THE FORMAT ABOVE>"
fi' -f
@fel-cesar
fel-cesar / DataStreamExt.swift
Created June 1, 2017 15:54
Data extension for initialization with Data
extension Data {
init(reading input: InputStream) {
self.init()
input.open()
let bufferSize = 1024
let buffer = UnsafeMutablePointer<UInt8>.allocate(capacity: bufferSize)
while input.hasBytesAvailable {
let read = input.read(buffer, maxLength: bufferSize)
@fel-cesar
fel-cesar / NSData+stream.m
Created June 1, 2017 14:19
Convert NSInputStream to NSData
+(NSData*) dataWithInputStream:(NSInputStream*) stream {
NSMutableData * data = [NSMutableData data];
[stream open];
NSInteger result;
uint8_t buffer[1024]; // BUFFER_LEN can be any positive integer
while((result = [stream read:buffer maxLength:1024]) != 0) {
if(result > 0) {
// buffer contains result bytes of data to be handled
@fel-cesar
fel-cesar / essential_terminal.sh
Last active February 22, 2017 12:44
This gist is a shellscript meant to list and install all the ESSENTIAL terminal applications
#TODO: check OS and use YUM, APT, OR BREW
#ohmyzsh
sudo apt-get install zsh
$ sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
sudo apt-get install httpie # awesome alternative to curl
//let cloudStorage : BusinessCloudStorageProtocol = Backblaze.init(accountID: "[account_id]", appKey: "[app_key]")
//let cloudStorage : BusinessCloudStorageProtocol = Rackspace.init(username: "[username]", apiKey: "[api_key]", region: "[region]")
//let cloudStorage : BusinessCloudStorageProtocol = MicrosoftAzure.init(accountName: "[account_name]", accessKey: "access_key")
let cloudStorage : BusinessCloudStorageProtocol = AmazonS3.init(accessKeyId: "[access_key]", secretAccessKey: "[secret_key]", region: "[region]")
let bucket : CRBucket = CRBucket.init()
bucket.name = "[bucketName]";
bucket.identifier = "[identifier]"
let path = Bundle.main.path(forResource: "UserData", ofType: "csv")!
// self.service = [[CRMicrosoftAzure alloc] initWithAccountName:@"[account_name]" accessKey:@"[access_key]"];
// self.service = [[CRAmazonS3 alloc] initWithAccessKeyId:@"[clientID]" secretAccessKey:@"[client_Secret]" region:@"[region]"];
// self.service = [[CRRackspace alloc] initWithUsername:@"[username]" apiKey:@"[api_key]" region:@"[region]"];
self.service = [[CRBackblaze alloc] initWithAccountID:@"[account_init]" appKey:@"[app_key]"];
CRBucket * bucket = [[CRBucket alloc] init];
bucket.name = @"[bucket_name]";
bucket.identifier = @"[bucket_id]";
NSData * data = //data source;
@fel-cesar
fel-cesar / StripExceedingArchs.sh
Created October 26, 2016 12:42
Script to strip off the exceeding architechtures from dynamic frameworks in xcode, (just add the script to build phases)
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
# This script loops through the frameworks embedded in the application and
# removes unused architectures.
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
@fel-cesar
fel-cesar / CSSwift.swift
Created October 21, 2016 10:52
Example CloudStorage Swift 3
//let cloudStorage : CloudStorageProtocol = Box.init(clientId: "ClientID", clientSecret: "ClientSecret")
//let cloudStorage : CloudStorageProtocol = GoogleDrive.init(clientId: "ClientID", clientSecret: "ClientSecret")
//let cloudStorage : CloudStorageProtocol = OneDrive.init(clientId: "ClientID", clientSecret: "ClientSecret")
//let cloudStorage : CloudStorageProtocol = Dropbox.init(clientId: "ClientID", clientSecret: "ClientSecret")
let cloudStorage : CloudStorageProtocol = Egnyte.init(domain: "DOMAIN", clientId: "[CLIENT]", clientSecret: "[SECRET]", redirectUri: "[REDIRECTURI]", state: "ANY")
let path = Bundle.main.path(forResource: "UserData", ofType: "csv")!
let fileAttributes = try! FileManager.default.attributesOfItem(atPath: path)
let fileSize: UInt64 = fileAttributes[FileAttributeKey.size] as! UInt64
@fel-cesar
fel-cesar / CSObjc.m
Last active October 21, 2016 10:10
Example CloudStorage Objective-C
// id<CRCloudStorageProtocol> cs = [[CROneDrive alloc] initWithClientId:@"[CLIENT]" clientSecret:@"[SECRET]"];
// id<CRCloudStorageProtocol> cs= [[CRGoogleDrive alloc] initWithClientId:@"[CLIENT]" clientSecret:@"[SECRET]"];
// id<CRCloudStorageProtocol> cs = [[CRBox alloc] initWithClientId:@"[CLIENT]" clientSecret:@"[SECRET]" ];
// id<CRCloudStorageProtocol> cs = [[CRDropbox alloc] initWithClientId:@"[CLIENT]" clientSecret:@"[SECRET]"];
id<CRCloudStorageProtocol> cs = [[CREgnyte alloc] initWithDomain:@"[DOMAIN]" clientId:@"[CLIENT]" clientSecret:@"" redirectUri:@"[SECRET]" state:@"ANY"];
NSString * path = [[NSBundle mainBundle] pathForResource:@"UserData" ofType:@"csv"];
NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:path error:nil];
long fileSize = [fileAttributes fileSize];
@fel-cesar
fel-cesar / build.sh
Created September 12, 2016 14:59 — forked from fjcaetano/build.sh
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