Skip to content

Instantly share code, notes, and snippets.

Avatar

Alejandro Ramirez janodev

View GitHub Profile
@janodev
janodev / project.yml
Created May 16, 2021
Xcodegen project
View project.yml
name: myproject
options:
bundleIdPrefix: com.myproject
usesTabs: false
indentWidth: 4
tabWidth: 4
createIntermediateGroups: true
deploymentTarget:
iOS: "14.5"
View SomeView.swift
import UIKit
final class SomeView: LayoutView
{
let view1 = UIView()
let view2 = UIView()
let view3 = UIView()
override func layout() {
super.layout()
View ioslocaleidentifiers.csv
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
mr Marathi
bs Bosnian
ee_TG Ewe (Togo)
ms Malay
kam_KE Kamba (Kenya)
mt Maltese
ha Hausa
es_HN Spanish (Honduras)
ml_IN Malayalam (India)
ro_MD Romanian (Moldova)
@janodev
janodev / AutoLayout.swift
Created Apr 30, 2019
Buttons with equal width using Visual Format Language
View AutoLayout.swift
import UIKit
public extension UIView {
var autoLayout: AutoLayout {
return AutoLayout(self)
}
}
@janodev
janodev / karabiner.json
Created Dec 10, 2018
My Karabiner rules containing "WASD arrow Keys toggled by Capslock". See https://stackoverflow.com/a/53698322/412916
View karabiner.json
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
@janodev
janodev / Makefile
Last active Aug 5, 2020
Securing Apache with client certificate authorisation
View Makefile
.DEFAULT_GOAL := hello
CA = ca
CA_NAME = Janodev CA
SERVER = jano
SERVER_DOMAIN = jano.dev
CLIENT = client
CLIENT_NAME = Janodev Notes User
SERVER_CONF = server.conf
CLIENT_CONF = client.conf
@janodev
janodev / idioms.swift
Last active Jun 29, 2018
initialising idioms
View idioms.swift
import UIKit
// this one doesn’t require a helper function
var label: UILabel = {
$0.backgroundColor = .blue
$0.text = "This is a playground"
$0.textColor = .white
$0.textAlignment = .center
return $0
View ObjC.h
#import <Foundation/Foundation.h>
@interface ObjC: NSObject
+ (BOOL)catchException:(void(^)(void))tryBlock error:(__autoreleasing NSError **)error;
@end
@janodev
janodev / ControllerLifecycle.swift
Created Apr 16, 2018
Unit testing a view controller
View ControllerLifecycle.swift
// From https://albertodebortoli.com/2018/03/12/easy-view-controller-unit-testing/
import XCTest
import UIKit
class ControllerLifecycle<T: UIViewController>
{
private lazy var this = type(of: self).self
private var rootWindow: UIWindow?
var rootController: T? {
@janodev
janodev / Downloader.swift
Created Apr 8, 2018
Weakly retaining an object in a closure without having to write [weak]
View Downloader.swift
// I saw this trick in “Do you often forget [weak self], here is a solution”
// https://medium.com/anysuggestion/preventing-memory-leaks-with-swift-compile-time-safety-49b845df4dc6
import UIKit
class ViewController: UIViewController {
// move this variable inside viewDidLoad to see it being released
let downloader = Downloader()