Skip to content

Instantly share code, notes, and snippets.

@LeonardoCardoso
LeonardoCardoso / GPG-Tower
Last active Dec 14, 2021
How to setup Tower to use the GPG Suite
View GPG-Tower
# GPG on Tower
@LeonardoCardoso
LeonardoCardoso / GitHubDark.css
Created Feb 9, 2017
MacDown GitHubDark Theme
View GitHubDark.css
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote {
margin: 0;
padding: 0;
View UIViewControllerExtension.swift
import UIKit
extension UIViewController {
static var topmostViewController: UIViewController? { return UIApplication.shared.keyWindow?.topmostViewController }
var topmostViewController: UIViewController? { return presentedViewController?.topmostViewController ?? self }
}
@LeonardoCardoso
LeonardoCardoso / combinations.py
Created Nov 29, 2016
Generate all combinations of a string, uppercase and lowercase.
View combinations.py
def recurse (pref,suff):
# If no characters left, just print prefix.
if suff == "":
print pref
return
# Otherwise add lowercase of first suffix letter to prefix
# and recur with that and the remainder of the suffix.
# Then do the same for uppercase.
@LeonardoCardoso
LeonardoCardoso / change-screen-shot-location.sh
Created Aug 31, 2016
Change Screen Shot location on Mac
View change-screen-shot-location.sh
defaults write com.apple.screencapture location ~/PATH_YOU_WANT; killall SystemUIServer
@LeonardoCardoso
LeonardoCardoso / better-touch-tool.plist
Last active Oct 30, 2018
Script to keep BetterTouchTool running.
View better-touch-tool.plist
<?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>
View xcode-build-and-test.sh
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 / DateConverterExtension.swift
Created Jul 4, 2016
Convert date from a format to another
View DateConverterExtension.swift
extension String {
func convertDateDFormat(from: String = "yyyy-mm-dd", to: String = "EEE dd/mm/yyyy") -> String! {
let dateOriginalFormat = NSDateFormatter()
dateOriginalFormat.dateFormat = from
let dateDestinationFormat = NSDateFormatter()
dateDestinationFormat.dateFormat = to
View add-space-on-dock.sh
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'
killall Dock
View StringExtension.swift
extension String {
var isCPF: Bool {
let cpf = self.stringByReplacingOccurrencesOfString(".", withString: "").stringByReplacingOccurrencesOfString("-", withString: "")
if cpf.characters.count == 11 {
let d1 = Int(cpf.substringWithRange(Range(cpf.startIndex.advancedBy(9) ..< cpf.startIndex.advancedBy(10))))
let d2 = Int(cpf.substringWithRange(Range(cpf.startIndex.advancedBy(10) ..< cpf.startIndex.advancedBy(11))))