Skip to content

Instantly share code, notes, and snippets.

View indyfromoz's full-sized avatar
🏠
Working from home

Indrajit Chakrabarty indyfromoz

🏠
Working from home
View GitHub Profile
@indyfromoz
indyfromoz / Go_Setup.md
Last active June 21, 2018 15:53
Go 1.8 setup on a Mac running Sierra 10.12.3+

Install Go with Homebrew

brew install go --cross-compile-common

Update Bash profile

export GOROOT=/usr/local/opt/go/libexec
@indyfromoz
indyfromoz / Obsidian.xccolortheme
Created March 30, 2017 20:18
Obsidian Xcode theme tested with Xcode 8.3
<?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>DVTConsoleDebuggerInputTextColor</key>
<string>1 1 1 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>SFMono-Bold - 11.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>1 1 1 1</string>
@indyfromoz
indyfromoz / cocoapods-install.md
Last active February 17, 2021 19:19
Installing & updating Cocoapods on a Mac
@indyfromoz
indyfromoz / SolarizedDark.xccolortheme
Created July 23, 2017 08:28
Solarized Dark Theme for Xcode 8+
#Remove this line after copying the following to ~/Library/Developer/Xcode/UserData/FontAndColorThemes/SolarizedDark.xccolortheme
<?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>DVTConsoleDebuggerInputTextColor</key>
<string>0.513725 0.580392 0.588235 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>Menlo-Regular - 11.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
@indyfromoz
indyfromoz / build.gradle
Created October 22, 2018 21:05
Build identifiers
ext {
// Assumes Git is in your PATH
commitCount = {
return 'git rev-list --count HEAD'.execute().text.trim()
}
gitSha = {
return 'git rev-parse --short HEAD'.execute().text.trim()
}
import UIKit
protocol ImageDownloadProtocol {
func downloadImage(from url: URL, completion: @escaping (UIImage?) -> Void)
}
extension ImageDownloadProtocol {
func downloadImage(from url: URL, completion: @escaping (UIImage?) -> Void) {
let session = URLSession(configuration: .default)
DispatchQueue.global(qos: .background).async {
@indyfromoz
indyfromoz / KeyedDecodingContainer.swift
Created December 29, 2019 06:38
JSON decoder that handles an absent value or a null value
extension KeyedDecodingContainer {
func decodeIfPresentAndNotNullString<T>(_ type: T.Type, forKey key: Key) throws -> T? where T: Decodable {
do {
return try decodeIfPresent(type, forKey: key)
} catch {
if let valueAsString = try decodeIfPresent(String.self, forKey: key), valueAsString == "<null>" {
return nil
} else {
throw error
}
@indyfromoz
indyfromoz / SelfSizingTableViewCells.swift
Created January 3, 2020 04:51
Self-sizing UITableView cell - Force update of UI
// Via @layoutSubviews in /dev/world2019
func tableView( _ tableView : UITableView, didSelectRowAt indexPath: IndexPath ) {
let cell = tableView.cellForRowAt( indexPath) as! MyCell
// Make some changes that affect the layout. Doing this but nothing else will cause clipped content.
cell.label.fontSize = 100
// We have to force the table view to recalculate the cell size and update the UI
tableView.beginUpdates()
tableView.endUpdates()
}