Skip to content

Instantly share code, notes, and snippets.

@LeonardoCardoso
LeonardoCardoso / better-touch-tool.plist
Last active October 30, 2018 09:57
Script to keep BetterTouchTool running.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN” "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>Label</key>
@LeonardoCardoso
LeonardoCardoso / add-space-on-dock.sh
Created June 22, 2016 11:41
Add space on Mac's Dock
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'
killall Dock
@LeonardoCardoso
LeonardoCardoso / Serializer.swift
Created May 31, 2016 13:05
JSON Serializer and Converter for URL and String
// JSON Serializer helper class
class Serializer {
// Retrieve JSON from Url and tries to parse it
static func jsonFromUrl(url: String, completionHandler: (NSDictionary) -> (), errorHandler: (NSError?) -> ()) {
let url = NSURL(string: url)
let task = NSURLSession.sharedSession().dataTaskWithURL(url!) {(data, response, error) in
@LeonardoCardoso
LeonardoCardoso / Reflection.swift
Created May 21, 2016 18:13
Get any class properties using reflection
// MARK: - Get properties using reflection
extension NSObject {
func properties() -> [String: String]{
var results: [String: String] = [:]
for child in Mirror(reflecting: self).children {
var propertyName = ""
class func executeAfter(delay: TimeInterval, block: @escaping () -> Void){
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + delay, execute: block)
}
import Foundation
extension String {
var parseJSON: AnyObject? {
let data = self.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)
if let jsonData = data {
@LeonardoCardoso
LeonardoCardoso / cpwd.sh
Last active October 30, 2018 09:59
One line command to copy the current terminal path on Mac
#...
alias cpwd="pwd | tr -d '\n' | pbcopy"
#...
@LeonardoCardoso
LeonardoCardoso / Podfile-Snippet
Last active October 30, 2018 09:59
Podfile Snippet: 'Build Active Architecture Only' to 'NO' and 'Valid Architectures' to '$(ARCHS_STANDARD)' to all pods
# insert this at the end of your Podfile
post_install do |installer|
installer.project.targets.each do |target|
target.build_configurations.each do |configuration|
target.build_settings(configuration.name)['ARCHS'] = '$(ARCHS_STANDARD)' # it sets 'Valid Architectures' to '$(ARCHS_STANDARD)' to all pods
target.build_settings(configuration.name)['ONLY_ACTIVE_ARCH'] = 'NO' # it sets 'Build Active Architecture Only' to 'NO'
end
end
end
@LeonardoCardoso
LeonardoCardoso / xcode-build-and-test.sh
Last active October 3, 2019 16:59
XCode Build and Test
xcodebuild -project YourProject.xcodeproj -scheme YourProjectScheme -destination "OS=10.0,name=iPhone 7" -sdk "iphonesimulator10.0" RUN_TESTS="YES" BUILD_EXAMPLE="NO" POD_LINT="NO" -configuration Debug ONLY_ACTIVE_ARCH=NO ENABLE_TESTABILITY=YES test | xcpretty -c;
xcodebuild -project YourProject.xcodeproj -scheme YourProjectSchemeWatchOS -destination "OS=3.0,name=Apple Watch Series 2 - 42mm" -sdk "watchsimulator3.0" RUN_TESTS="NO" BUILD_EXAMPLE="NO" POD_LINT="NO" -configuration Debug ONLY_ACTIVE_ARCH=NO build | xcpretty -c;
xcodebuild -project YourProject.xcodeproj -scheme YourProjectSchemeTvOS -destination "OS=10.0,name=Apple TV 1080p" -sdk "appletvsimulator10.0" RUN_TESTS="YES" BUILD_EXAMPLE="NO" POD_LINT="NO" -configuration Debug ONLY_ACTIVE_ARCH=NO ENABLE_TESTABILITY=YES test | xcpretty -c;
xcodebuild -project YourProject.xcodeproj -scheme YourProjectSchemeMacOS -destination "arch=x86_64" -sdk "macosx10.12" RUN_TESTS="YES" BUILD_EXAMPLE="NO"
@LeonardoCardoso
LeonardoCardoso / simulatorFullScreen.sh
Last active November 25, 2019 23:40
iOS Simulator Full screen
defaults write com.apple.iphonesimulator AllowFullscreenMode -bool YES