Skip to content

Instantly share code, notes, and snippets.

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

Luke Redpath lukeredpath

🏠
Working from home
View GitHub Profile
@lukeredpath
lukeredpath / AutocompleteWeirdness-1.swift
Created May 4, 2021 14:32
Xcode autocomplete behaviour depends on source order
import Combine
import Foundation
let wrapper = Wrapper(createPublisher: { Just("foo").eraseToAnyPublisher() })
// This will not produce any auto-complete suggestions
wrapper.createPublisher().
struct Wrapper {
var createPublisher: () -> AnyPublisher<String, Never>
// Compiles in Xcode 12.5, but not 12.4
var foo: Foo {
#if DEBUG
Foo(debug: true)
#else
Foo()
#end
}
// Compiles in both
@lukeredpath
lukeredpath / LICENSE
Last active April 7, 2021 14:13
Unwrapping embedded case values in TCA test store tests
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
@lukeredpath
lukeredpath / jetbrains.teamcity.BuildAgent.plist
Created November 14, 2012 17:22
Launcher for TeamCity OSX Build Agent
<?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>WorkingDirectory</key>
<string>/Users/teamcity/TeamCity/buildAgent</string>
<key>Debug</key>
<false/>
<key>Label</key>
<string>jetbrains.teamcity.BuildAgent</string>
@lukeredpath
lukeredpath / AssertEventually.h
Created August 3, 2010 13:20
Enables simple and elegant testing of asynchronous/threaded code with OCUnit, blocks and OCHamcrest
//
// AssertEventually.h
// LRResty
//
// Created by Luke Redpath on 03/08/2010.
// Copyright 2010 LJR Software Limited. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "HCMatcher.h"
extension Data {
// Returns a base64 encoded string, replacing reserved characters
// as per https://tools.ietf.org/html/rfc7636#section-4.2
func pkce_base64EncodedString() -> String {
base64EncodedString()
.replacingOccurrences(of: "+", with: "-")
.replacingOccurrences(of: "/", with: "_")
.replacingOccurrences(of: "=", with: "")
.trimmingCharacters(in: .whitespaces)
}
private func hexString(_ iterator: Array<UInt8>.Iterator) -> String {
return iterator.map { String(format: "%02x", $0) }.joined()
}
let exampleVerifier = "kM83K571n5KFW9u29Xu2qSqgoUwep4I2jZw8FGZg4Yr"
let verifierData = exampleVerifier.data(using: .utf8)!
// CommonCrypto implementation
var buffer = [UInt8](repeating: 0, count: Int(CC_SHA256_DIGEST_LENGTH))
_ = verifierData.withUnsafeBytes { CC_SHA256($0.baseAddress, CC_LONG(verifierData.count), &buffer) }
require 'fileutils'
REPORT_FOLDER = Pathname.new('/Users/luke/Documents/Business/Accounts/iTunes Finance Reports')
@agent = ITunesConnect::Agent.new
@agent.sign_in!('your@email.com', 'yourpassword')
begin
if @agent.signed_in?
@downloaded = 0
@lukeredpath
lukeredpath / RawRepresentable+Parsing.swift
Created January 3, 2021 01:45
Swift enum parsing using the swift-parsing library
extension RawRepresentable where Self.RawValue == String {
/// Parses out the first matching raw value from a list of possible values, or returns nil.
///
/// Example:
///
/// enum SomeValues: String, CaseIterable {
/// case one
/// case two
/// }
///
struct TaggedOutput<Output> {
let token: AnyHashable
let output: Output
}
struct Effect<Output>: Publisher {
typealias Failure = Never
let base: AnyPublisher<TaggedOutput<Output>, Failure>
let token: AnyHashable