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]
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])
}
}
@fjcaetano
fjcaetano / export-ipa.sh
Created November 18, 2021 20:33
Manually export an iOS enterprise build
#! /bin/sh
ARCHIVE_PATH="$1"
OUTPUT_PATH="$2"
if [ -z "${ARCHIVE_PATH}" ] || [ -z "${OUTPUT_PATH}" ]; then
echo "Usage: $0 [archive_path] [output_path]"
exit 1
fi
TMP_PATH="/tmp/manual-archive"
@fjcaetano
fjcaetano / DispatchQueue+DebounceThrottle.swift
Last active September 23, 2021 07:25
Debounce + Throttle
import Dispatch
private var throttleWorkItems = [AnyHashable: DispatchWorkItem]()
private var lastDebounceCallTimes = [AnyHashable: DispatchTime]()
private let nilContext: AnyHashable = arc4random()
public extension DispatchQueue {
/**
- parameters:
- deadline: The timespan to delay a closure execution
@fjcaetano
fjcaetano / codecov.rb
Last active February 8, 2021 19:59
Codecov Fastlane action
module Fastlane
module Actions
class CodecovAction < Action
def self.run(params)
ci_only = params[:ci_only]
cmd = ['curl -s https://codecov.io/bash | bash']
cmd << "-s --" if params.all_keys.inject(false) { |p, k| p or params[k] }
cmd << "-X xcodeplist" if params[:use_xcodeplist]
cmd << "-J '#{params[:project_name]}'" if params[:project_name]
@fjcaetano
fjcaetano / ios_simulator.rb
Created November 13, 2017 16:09
iOS Simulator launcher Fastlane action
module Fastlane
module Actions
module SharedValues
IOS_SIMULATOR_CUSTOM_VALUE = :IOS_SIMULATOR_CUSTOM_VALUE
end
class IosSimulatorAction < Action
@@already_booted_code = 164
def self.run(params)
@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
@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:

Keybase proof

I hereby claim:

  • I am fjcaetano on github.
  • I am fjcaetano (https://keybase.io/fjcaetano) on keybase.
  • I have a public key ASBPByTOBjczHP-AUH3vIlMW7Lq2bslvhRAJTTU63iW6ego

To claim this, I am signing this object:

@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
@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} />;
}
}