Skip to content

Instantly share code, notes, and snippets.

View Raafas's full-sized avatar
🦁
0x8badf00d

Rafael Leandro Raafas

🦁
0x8badf00d
  • Florianópolis, SC - Brazil
View GitHub Profile
@Raafas
Raafas / iphone-simulator-app-folder.sh
Created October 15, 2021 20:45 — forked from atika/iphone-simulator-app-folder.sh
Open the iOS Simulator folder containing -user defaults- plists files for your Application
#!/bin/bash
appname="$1"
[ -z $appname ] && read -p "Application name : " appname
apppath=$(find ~/Library/Developer/CoreSimulator/Devices/ -name "$appname.app" -print -quit)
if [[ ! -z $apppath ]]; then
echo "Found path for $appname app"
echo -e "\033[1;30m$apppath\033[0m"
appbundle=$(osascript -e "id of app \"$apppath\"")
@Raafas
Raafas / DecodableRoot.swift
Created October 14, 2021 14:44 — forked from htinlinn/DecodableRoot.swift
Decode JSON at root level based on a key
extension JSONDecoder {
func decode<T: Decodable>(_ type: T.Type, from data: Data, keyedBy key: String?) throws -> T {
if let key = key {
// Pass the top level key to the decoder.
userInfo[.jsonDecoderRootKeyName] = key
let root = try decode(DecodableRoot<T>.self, from: data)
return root.value
} else {
@Raafas
Raafas / FirebaseCoordinator.swift
Created April 13, 2020 14:04 — forked from steipete/FirebaseCoordinator.swift
If you're as confused as I am that there's an API for custom options, yet Google still requires a file named GoogleService-Info.plist in your app, here's some swizzling that fixes that for ya. All Swift :)
class FirebaseCoordinator {
static let shared = FirebaseCoordinator()
static let initialize: Void = {
/// We modify Google Firebase (and eventually Analytics) to load the mac-specific plist at runtime.
/// Google enforces that we have a file named "GoogleService-Info.plist" in the app resources.
/// This is unfortunate since we need two different files based on iOS and Mac version
/// One solution is a custom build step that copies in the correct file:
/// https://stackoverflow.com/questions/37615405/use-different-googleservice-info-plist-for-different-build-schemes
/// However, this is basically impossible since Catalyst doesn't set any custom build variables, so detection is extremely difficult.
/// We swizzle to modify the loading times.
@Raafas
Raafas / ios_header_remover.swift
Created January 24, 2020 17:24 — forked from rockbruno/ios_header_remover.swift
iOS File Header remover script
import Foundation
func findFiles(rootPath: String, suffix: String, ignoreDirs: Bool = true) -> [String]? {
var result = [String]()
let fileManager = FileManager.default
if let paths = fileManager.subpaths(atPath: rootPath) {
let swiftPaths = paths.filter { $0.hasSuffix(suffix) }
for path in swiftPaths {
var isDir : ObjCBool = false
let fullPath = (rootPath as NSString).appendingPathComponent(path)
@Raafas
Raafas / UIDevice+serialNumber.h
Created April 20, 2018 18:22 — forked from 0xced/UIDevice+serialNumber.h
UIDevice+serialNumber
/*
* Adds the serialNumber property to the UIDevice class
*
* The implementation uses undocumented (for iOS) IOKit functions,
* so handle with caution and be prepared for nil.
*/
#import <UIKit/UIDevice.h>
@interface UIDevice (serialNumber)
import Foundation
private var throttleWorkItem: DispatchWorkItem?
private var lastDebounceCallTime: DispatchTime?
public extension DispatchQueue {
/**
- parameters:
- deadline: The timespan to delay a closure execution
- action: The closure to be executed
@Raafas
Raafas / introrx.md
Created April 24, 2017 05:42 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
target 'YouApp' do
use_frameworks!
# Pods for YouApp
pod 'SwiftFramework', :branch => 'swift-2.3'
end