Skip to content

Instantly share code, notes, and snippets.

View jimmyhoran's full-sized avatar
🛠️
Working on my own thing

Jimmy Horan jimmyhoran

🛠️
Working on my own thing
View GitHub Profile
@stevencurtis
stevencurtis / subscriptCollection
Created November 20, 2019 12:19
subscriptCollection
extension Collection {
subscript(index i : Index) -> Element? {
return indices.contains(i) ? self[i] : nil
}
}
sliceOfArray[index: 0]
@stevencurtis
stevencurtis / indicies.contains
Created November 20, 2019 11:09
indicies.contains
if array.indices.contains(3) {
print (array[3])
}
@mattt
mattt / UIViewControllerPreview.swift
Last active December 3, 2024 07:42
Generic structures to host previews of UIView and UIViewController subclasses.
import UIKit
#if canImport(SwiftUI) && DEBUG
import SwiftUI
struct UIViewControllerPreview<ViewController: UIViewController>: UIViewControllerRepresentable {
let viewController: ViewController
init(_ builder: @escaping () -> ViewController) {
viewController = builder()
}
@jpsim
jpsim / FB6395442.md
Created July 24, 2019 03:24
FB6395442: Running 'xcodebuild archive' on a SwiftPM product produces different results than an equivalent .xcodeproj

An Xcode project generates the following archive:

$ tree Yams-macosx.xcarchive
Yams-macosx.xcarchive
├── Info.plist
├── Products
│   └── Library
│       └── Frameworks
│           └── Yams.framework
@szotp
szotp / swagger.swift
Last active January 6, 2021 02:26
Extremely generic swagger client
import Foundation
typealias ApiCallback<Output> = Optional<(Result<Output, Error>) -> Void>
protocol EndpointClient {
func execute<Output>(endpoint: Endpoint<Output>, onResult: ApiCallback<Output>)
}
struct RequestBuilder {
var path: String = ""
@mrk-han
mrk-han / emulator-install-using-avdmanager.md
Last active July 1, 2025 22:36
Installing and creating Emulators with AVDMANAGER (For Continuous Integration Server or Local Use)

Install and Create Emulators using AVDMANAGER and SDKMANAGER

TL;DR

For an emulator that mimics a Pixel 5 Device with Google APIs and ARM architecture (for an M1/M2 Macbook):

  1. List All System Images Available for Download: sdkmanager --list | grep system-images

  2. Download Image: sdkmanager --install "system-images;android-30;google_atd;arm64-v8a"

@manekinekko
manekinekko / open-in-cloud-shell.md
Last active July 6, 2025 00:37
gcloud.tips: use the Google Cloud Shell to clone and edit a github repository

Open a github repository in the Cloud Shell

The Google Cloud Shell gives you a handy and quick Shell access to your Cloud instance. One thing you may not know is that you can use the Cloud Shell to clone and edit a Github project. Let's see how.

The trick here is to just call the following URL: https://console.cloud.google.com/cloudshell/open with the following parameters:

  1. git_repo: this is the URL to your github repository
  2. open_in_editor: this would be the file you want to open in the editor
  3. page=editor: this tells the cloud shell to open the code editor
@hilalbaig
hilalbaig / UINavigationBar+Height.swift
Last active November 13, 2020 19:24 — forked from siberianisaev/UINavigationBar+Height.swift
Change height of UINavigationBar - Swift 3
import Foundation
import UIKit
private var AssociatedObjectHandle: UInt8 = 0
extension UINavigationBar {
var height: CGFloat {
get {
if let h = objc_getAssociatedObject(self, &AssociatedObjectHandle) as? CGFloat {
@lattner
lattner / TaskConcurrencyManifesto.md
Last active July 14, 2025 18:41
Swift Concurrency Manifesto
@ninjaprox
ninjaprox / bump-version.sh
Created February 26, 2017 10:41
Bump version in Info.plist
#!/bin/bash
component=$1
version=$(/usr/libexec/PlistBuddy -c 'Print CFBundleShortVersionString' Info.plist)
IFS="." read major minor patch <<< "$version"
echo "$version"
if [[ "$component" = 'major' ]]; then