Skip to content

Instantly share code, notes, and snippets.

View jschmid's full-sized avatar
📱

Jonas Schmid jschmid

📱
View GitHub Profile
@HiddenJester
HiddenJester / UnitTestingSceneDelegateGist.md
Last active March 20, 2024 14:38
Mocking SceneDelegate for Unit Tests on iOS 13

Replacing the SceneDelegate When Running Unit Tests

Overview

I've been working through the exercises in the excellent iOS Unit Testing by Example book by Jon Reid, which I highly recommend. However, the book is in beta at the moment and there are some curveballs thrown by iOS 13 that aren't handled in the text yet. Specifically, when I hit the section about using a testing AppDelegate class I thought "This is very good. But what about the SceneDelegate?"

In Chapter 4 the recommendation is to remove the @UIApplicationMain decoration and make a manual top-level call to UIApplicationMain. To wit:

import UIKit
@kairos34
kairos34 / ZipManager
Created March 19, 2019 15:06
Kotlin zip and unzip functions
object ZipManager {
fun zip(files: List<File>, zipFile: File) {
ZipOutputStream(BufferedOutputStream(FileOutputStream(zipFile))).use { output ->
files.forEach { file ->
(file.length() > 1).ifTrue {
FileInputStream(file).use { input ->
BufferedInputStream(input).use { origin ->
val entry = ZipEntry(file.name.toRealName())
output.putNextEntry(entry)
@lattner
lattner / TaskConcurrencyManifesto.md
Last active May 1, 2024 15:48
Swift Concurrency Manifesto
@lattner
lattner / async_swift_proposal.md
Last active April 21, 2024 09:43 — forked from oleganza/async_swift_proposal.md
Concrete proposal for async semantics in Swift

Async/Await for Swift

Introduction

Modern Cocoa development involves a lot of asynchronous programming using closures and completion handlers, but these APIs are hard to use. This gets particularly problematic when many asynchronous operations are used, error handling is required, or control flow between asynchronous calls gets complicated. This proposal describes a language extension to make this a lot more natural and less error prone.

This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.

@dickolsson
dickolsson / genesis.json
Last active April 29, 2024 09:24
Example genesis.json for an Ethereum blockchain
{
"config": {
"chainId": 33,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"nonce": "0x0000000000000033",
"timestamp": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
@benbahrenburg
benbahrenburg / PasscodeUtils.swift
Last active July 8, 2020 13:00
Use Swift to determine if device has passcode set
//
// PasscodeUtils.swift
//
// Created by Ben Bahrenburg on 12/31/16.
// Copyright © 2016 bencoding.com. All rights reserved.
//
import Foundation
import LocalAuthentication
@gbuesing
gbuesing / Gemfile
Last active October 28, 2020 16:01
ActiveJob with resque-scheduler on Heroku
gem 'resque-scheduler'
@mikelehen
mikelehen / generate-pushid.js
Created February 11, 2015 17:34
JavaScript code for generating Firebase Push IDs
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/
@gabrielemariotti
gabrielemariotti / Readme.md
Last active March 2, 2024 23:10
A SimpleSectionedRecyclerViewAdapter: use this class to realize a simple sectioned `RecyclerView.Adapter`.

You can use this class to realize a simple sectioned RecyclerView.Adapter without changing your code.

The RecyclerView should use a LinearLayoutManager. You can use this code also with the TwoWayView with the ListLayoutManager (https://github.com/lucasr/twoway-view)

This is a porting of the class SimpleSectionedListAdapter provided by Google

Screen

Example:

@davidjrice
davidjrice / .travis.yml
Last active October 23, 2019 16:17 — forked from johanneswuerbach/.travis.yml
Travis CI + TestFlight integration (updated for Travis' new Mac VM setup / xctool)
language: objective-c
xcode_workspace: "<WorkspaceName.xcworkspace>"
xcode_scheme: "<SchemaName>"
script: xctool -workspace <WorkspaceName.xcworkspace> -scheme <SchemeName> -configuration Release build archive
before_script:
- ./scripts/travis/add-key.sh
after_script:
- ./scripts/travis/remove-key.sh
after_success:
- ./scripts/travis/testflight.sh