Skip to content

Instantly share code, notes, and snippets.

View reejosamuel's full-sized avatar

Reejo Samuel reejosamuel

View GitHub Profile
@reejosamuel
reejosamuel / gpg-agent.conf
Last active December 7, 2020 00:44 — forked from bmhatfield/.profile
Automatic Git commit signing with GPG on OSX
# Connects gpg-agent to the OSX keychain via the brew-installed
# pinentry program from GPGtools. This is the OSX 'magic sauce',
# allowing the gpg key's passphrase to be stored in the login
# keychain, enabling automatic key signing.
pinentry-program /usr/local/bin/pinentry-mac
@reejosamuel
reejosamuel / FileIO.swift
Created October 23, 2017 15:31
read and write files
let file = "file.txt" //this is the file. we will write to and read from it
let text = "some text" //just a text
if let dir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first {
let fileURL = dir.appendingPathComponent(file)
//writing
do {
@reejosamuel
reejosamuel / OperationsQueuesTest.swift
Created October 17, 2017 09:37
Operation and Dispatch queue executions
let queue1 = DispatchQueue(label: "com.reejo.test",
qos: .userInitiated,
attributes: .concurrent,
autoreleaseFrequency: .inherit,
target: DispatchQueue.global())
queue1.async {
print("welcome!")
}
@reejosamuel
reejosamuel / UIColor+Ext.swift
Created October 16, 2017 18:47
UIColor extensions for hex color
extension UIColor {
public convenience init(hex: UInt32) {
let mask = 0x000000FF
let r = Int(hex >> 16) & mask
let g = Int(hex >> 8) & mask
let b = Int(hex) & mask
let red = CGFloat(r) / 255
@reejosamuel
reejosamuel / load_plist.swift
Last active October 16, 2017 18:33
Loading another plist file for settings.
if let path = Bundle.main.path(forResource: "<#nameOfPlist#>", ofType: "<#plist#>"),
let myDict = NSDictionary(contentsOfFile: path),
let apiKey = myDict.value(forKey: "API_Key") as? String {
print("API Key: \(apiKey)")
}
@reejosamuel
reejosamuel / SimpleStringCache.swift
Last active October 14, 2017 11:58
Implementing a simple string cache
class StringCache: NSCache<NSString, String> {
static let shared = ImageCache()
func set(_ text: String, for keyString: String) {
self.setObject(text, forKey: keyString as NSString)
}
func textFrom(_ keyString: String?) -> String? {
guard let keyString = keyString else {
@reejosamuel
reejosamuel / release-checklist.md
Last active October 3, 2017 10:27
In the early days of iOS, A realease checklist was very handy

Prerelease checklist

Type Action
App name insert content
Version insert content
Date of submission insert content

This form is to document the testing that has been done on each app

/*
See LICENSE folder for this sample’s licensing information.
Abstract:
`ImageCacheManager` serves as a simple image cache for caching media artwork from a remote server.
*/
import UIKit
class ImageCacheManager {
@reejosamuel
reejosamuel / ReejoUIScrollView.swift
Created December 6, 2016 08:08
UITableView on a UIScrollView, passing gestures to swipe cell in UITableView
//
// CAPSScrollView.swift
// Pods
//
// Created by Reejo Samuel on 12/6/16.
//
//
import Foundation
import UIKit
@reejosamuel
reejosamuel / breakpoint
Created August 15, 2016 11:54
Setup up breakpoint on a method call
breakpoint set -n openURL
breakpoint set -S openURL: