Skip to content

Instantly share code, notes, and snippets.

View finestructure's full-sized avatar

Sven A. Schmidt finestructure

View GitHub Profile
@finestructure
finestructure / LinuxMain.stencil
Last active November 28, 2018 11:59
Stencil file to autogenerate swift package manager linux tests with Sourcery
import XCTest
{{ argument.testimports }}
// swiftlint:disable trailing_comma
{% for type in types.classes|based:"XCTestCase" %}
{% if not type.annotations.disableTests %}extension {{ type.name }} {
static var allTests: [(String, ({{ type.name }}) -> () throws -> Void)] = [
{% for method in type.methods %}
{% if method.parameters.count == 0 and method.shortName|hasPrefix:"test" %}
// Add a marker protocol to allow for new TestCase subclasses to be
// picked up automatically by adopting it.
protocol LinuxTesting {}
// Extend XCTestCase to conform
extension XCTestCase: LinuxTesting {}
@finestructure
finestructure / OrderedDict.swift
Last active September 13, 2020 14:20
Swift ordered dictionary
import Foundation
struct OrderedDictionary<K: Hashable, V> {
var keys: [K] = []
var dict: [K: V] = [:]
var count: Int {
assert(keys.count == dict.count, "internal inconsistency")
return keys.count
! ◰³ james ~/P/E/james ⎇ develop *$- backend pytest tests/test_magic_links.py::MagicLinkTests::test_reuse_2
=========================================================================================================================== test session starts ===========================================================================================================================
platform darwin -- Python 3.7.2, pytest-4.6.2, py-1.8.0, pluggy-0.12.0
Django settings: test_settings (from ini file)
rootdir: /Users/sas/Projects/Enervolution/james/backend, inifile: setup.cfg
plugins: django-3.5.0
collected 1 item
tests/test_magic_links.py
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> PDB set_trace (IO
# Run with Rester: https://github.com/finestructure/Rester
variables:
BASE_URL: https://api.github.com/repos/brentsimmons/NetNewsWire
requests:
releases:
url: ${BASE_URL}/releases
headers:
# If you're getting rate limited by the Github API, run this
# restfile with a Github token.
# Uncomment the line starting with "Authorization:" below and
@finestructure
finestructure / make-spm-playground.sh
Last active August 12, 2020 01:19
Make a playground with access to an SPM library ready for importing
#!/usr/bin/env bash
set -eux
PROJ_NAME=myproj2
PKG_URL=https://github.com/johnsundell/plot.git
PKG_FROM=0.1.0
LIB_NAME=Plot
SWIFT_VERSION=5.1.3
PLATFORM=macos
@finestructure
finestructure / dispatchMain.swift
Created February 10, 2020 06:30
Swift scripting example use of dispatchMain
#!/usr/bin/env swift
import Foundation
import Dispatch
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
print("Done.")
exit(EXIT_SUCCESS)
}
@finestructure
finestructure / Readme.md
Last active June 23, 2020 03:09
Homebrew app release
// Playground generated with 🏟 Arena (https://github.com/finestructure/arena)
// ℹ️ If running the playground fails with an error "no such module ..."
// go to Product -> Build to re-trigger building the SPM package.
// ℹ️ Please restart Xcode if autocomplete is not working.
// Created by running
// arena git@github.com:stephencelis/swift-composable-architecture.git@revision:63b04f284a557d36d5c09d60dafb6e016b3432b8 -n text-field
import ComposableArchitecture
import ComposableArchitectureTestSupport
@finestructure
finestructure / CAProtocols.swift
Last active April 14, 2020 07:58
"Guidance protocols" for Composable Architecture
//
// CAProtocols.swift
// RequirementEditor
//
// Created by Sven A. Schmidt on 29/03/2020.
// Copyright © 2020 finestructure. All rights reserved.
//
import SwiftUI