Skip to content

Instantly share code, notes, and snippets.

View jaderfeijo's full-sized avatar

Jader Feijo jaderfeijo

View GitHub Profile
@jaderfeijo
jaderfeijo / ExampleTest.m
Created January 5, 2022 09:19 — forked from pk/ExampleTest.m
Using method swizzling and blocks to test Class methods in Objective-C.
#import "SenTestCase+MethodSwizzling.m"
@interface ExampleTest : SenTestCase {}
+ (BOOL)trueMethod;
+ (BOOL)falseMethod;
@end
@implementation ExampleTest
+ (BOOL)trueMethod { return YES; }
@jaderfeijo
jaderfeijo / pull-private.sh
Created January 23, 2020 23:36 — forked from Avaq/pull-private.sh
Exporting and importing GPG keys over SSH
ssh user@remote gpg --export-secret-key KeyId | gpg --allow-secret-key-import --import
@jaderfeijo
jaderfeijo / 1-setup.md
Created September 5, 2019 13:35 — forked from troyfontaine/1-setup.md
Signing your Git Commits using GPG on MacOS Sierra/High Sierra

Methods of Signing with GPG

There are now two ways to approach this:

  1. Using gpg and generating keys
  2. Using Kryptonite by krypt.co

This Gist explains how to do this using gpg in a step-by-step fashion. Kryptonite is actually wickedly easy to use-but you will still need to follow the instructions

For using a GUI-based GIT tool such as Tower or Github Desktop, follow the steps here for signing with either GPG or Krypt.co.

@jaderfeijo
jaderfeijo / Collection+SafeElementRetrieval.swift
Last active June 19, 2018 10:14
Safe element retrieval for Swift collections
infix operator ~>: DefaultPrecedence
extension Collection {
/// Returns the element at the specified index if it is within bounds, otherwise nil.
///
/// This extension allows you to write code as follows:
/// - Example:
/// ```
/// if let element = array ~> index {
@jaderfeijo
jaderfeijo / SwiftyExpectations.swift
Last active June 11, 2018 15:20
SwiftyExpectations
//
// SwiftyExpectations.swift
//
// Created by Jader Feijo.
//
import Foundation
import XCTest
/// A wrapper around `XCTExpectation` which provides
@jaderfeijo
jaderfeijo / gist:c6ac4afbd3532bd86d0ee876062c2db7
Created May 2, 2018 16:07 — forked from nateware/gist:3915757
Start Mac VNC server from command line
# Step 1: Set priveleges
$ sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -allowAccessFor -allUsers -privs -all
Starting...
Setting allow all users to YES.
Setting all users privileges to 1073742079.
Done.
# Step 2: Allow VNC clients
@jaderfeijo
jaderfeijo / URL+QueryStrings.swift
Last active March 13, 2018 10:44
URL+QueryStrings.swift
import Foundation
extension URL {
var hasQueryStringParameters: Bool {
return query != nil
}
var queryStringParameters: [String: String] {
var results = [String: String]()
if let keyValues = query?.components(separatedBy: "&"), keyValues.count > 0 {
@jaderfeijo
jaderfeijo / NumberFormatter+Currency.swift
Last active March 13, 2018 10:45
NumberFormatter+Currency.swift
//
// NumberFormatter+Currency.swift
// Created by: Jader Feijo
//
import Foundation
extension NumberFormatter {
public static func formatter(forCurrencyCode currencyCode: String) -> NumberFormatter {
return NumberFormatter().with { f in
@jaderfeijo
jaderfeijo / Array+NaturalLanguageJoin.swift
Last active March 13, 2018 10:45
Array+NaturalLanguageJoin.swift
//
// Array+NaturalLanguageJoin.swift
// Created by: Jader Feijo
//
import Foundation
extension Array {
var joinedAsNaturalLanguageSequence: String {
var naturalLanguageSequence = ""
@jaderfeijo
jaderfeijo / Date+Components.swift
Last active March 13, 2018 10:45
Date+Components.swift
//
// Date+Components.swift
// Created by: Jader Feijo
//
import Foundation
extension Date {
var hour: Int {
return (Calendar.current as NSCalendar).component(.hour, from: self)