lukeredpath

lukeredpath

iOS and Ruby software engineer.

Member Since 13 years ago

LJR Software Limited, Colchester, UK

Experience Points
538
follower
Lessons Completed
8
follow
Lessons Completed
127
stars
Best Reply Awards
98
repos

2110 contributions in the last year

Pinned
⚡ A SwiftUI wrapper around UITextField with binding-based state and responder control
⚡ A protocol-witness oriented library built on top of Codable
⚡ A high-level functional validation library, written in Swift
⚡ State-driven URL opening for The Composable Architecture
⚡ A small example of how to use OAuth in a SwiftUI app with PKCE
⚡ Proof of concept OAuth provider proxy server that adds PKCE support for public clients
Activity
Jan
26
1 day ago
push

lukeredpath push lukeredpath/dotfiles

lukeredpath
lukeredpath

Move sensitive and device local config into a separate file

commit sha: 2227d62c52c5b15ff69caa0e8afcadea5427dcdf

push time in 13 hours ago
push

lukeredpath push lukeredpath/dotfiles

lukeredpath
lukeredpath

Disable theme in favour of starship

commit sha: 3dd83937ff1d6544ae040d7e2ba1738d26639f5f

push time in 13 hours ago
Activity icon
created branch
createdAt 14 hours ago
Activity icon
delete
deleted time in 14 hours ago
push

lukeredpath push lukeredpath/dotfiles

lukeredpath
lukeredpath

Move aliases to a separate file.

lukeredpath
lukeredpath
lukeredpath
lukeredpath

Merge branch 'master' of github.com:lukeredpath/dotfiles

commit sha: 77f1394601e21e171eaf1ae3204ab595ed48e3aa

push time in 14 hours ago
Activity icon
issue

lukeredpath issue comment pointfreeco/swift-snapshot-testing

lukeredpath
lukeredpath

Snapshots on Apple Silicon devices

It seems that Apple Silicon machines generate snapshots that are slightly different from the ones generated on x86 machines. The problem is very similar to the one where the very same simulator generates different images depending on the OS version.

The issues persist when running the simulator using Rosetta.

Taking into account that it’ll be quite common in the near future to have a team of developers with Intel and Apple Silicon architectures… What’s the best way to handle it?

Thanks

lukeredpath
lukeredpath

We're also having this problem as we start transitioning developer devices to Apple Silicon, while some of us are still going to be on Intel for a while longer. There are really two issues at play here:

  • Where the snapshots are generated originally.
  • Where the snapshots are verified.

Any solutions involving standardising where these things happen is difficult to achieve - some developers will be on Intel by choice, some are on M1. Our CI currently only supports Intel and we have no ETA on Apple Silicon support. That leaves us with needing to be able to verify snapshots accurately on Intel machines.

Of course, if snapshots need to always be verifiable on Intel, that means we cannot generate snapshots on Apple Silicon machines, which makes life very difficult for developers on M1s as they cannot generate new or updated snapshots unless we can find some kind of automated way (like a Github Action) that re-generates new and updated snapshots on an Intel executor and re-commits them. This is currently an option we're considering but I'd prefer to avoid this.

I think the best solution to this problem is a revised image diffing strategy that can account for minor differences between the two architectures. We have tried adjusting the precision with mixed results - sometimes it makes a test pass, sometimes it does not. Additionally, it seems that changing the precision has a serious impact on performance - I've seen a fairly big test with 10 snapshots take 10x longer by changing the precision from 1.0 to 0.99 - it took over 40 seconds!

I'd like to try the SnapshotTestingEx solution above but unfortunately it looks like this needs a patched version of SnapshotTesting - it would be great to get some movement on this. I'm curious if @stephencelis or @mbrandonw have run into this issue in their own apps and if they've found a solution.

Jan
11
2 weeks ago
Activity icon
issue

lukeredpath issue comment pointfreeco/swift-parsing

lukeredpath
lukeredpath

Add support for parsing enum raw string values

Description

This PR adds support for parsing raw enum values off the beginning of Input and returning the enum value in the following ways:

  • A Parsers.enumRawValue(in:) function that returns a parser.
  • An opt-in high-level API as extensions on a custom CaseParsable protocol that enums can conform to.

Use case

A common task might be to parse some kind of input into a local domain model which may frequently include some kind of enumerated type. For example, given the following string:

"thing:type_a:type_b"

And the following types:

struct Thing {
  var type_a: TypeA
  var type_b: TypeB
}

enum TypeA: String, CaseIterable {
  case one
}

enum TypeB: String, CaseIterable {
  case two
}

Using the new enum case parser you could construct a Parser<Substring, Thing> as follows:

let thingParser = StartsWith("thing:")
    .take(Parsers.enumRawValue(in: TypeA.allCases))
    .skip(StartsWith(":"))
    .take(Parsers.enumRawValue(in: TypeB.allCases))
    .map(Thing.init(type_a:type_b:))

Or, by opting the enums into the CaseParsable protocol the above could be rewritten as:

let thingParser = StartsWith("thing:")
    .take(TypeA.firstMatchingCase)
    .skip(StartsWith(":"))
    .take(TypeB.firstMatchingCase)
    .map(Thing.init(type_a:type_b:))

Discussion

I originally implemented this in a Swift playground purely as an extension on the RawRepresentable protocol however I feel like libraries should avoid adding behaviour to built-in types by default and this should be opt-in, which is why the main parsing logic is implemented as a static function on Parsers and the high-level API implemented as default implementations on a custom protocol. Conforming to the CaseParsable protocol feels like a fairly unobtrusive way to gain extra functionality and is inspired by the similarly named CaseIterable protocol.

This PR only adds support for parsing string raw values but could be extended to support other raw value types such as Int although I feel like String would be the common use-case for this.

Main points for discussion are:

  • Is implementing the base parser as a static function the best way of going about this? Because it's entirely constructed by composing existing parsers it felt overkill to create an entirely new Parser type. Is there a better approach?
  • Naming - naming is hard, do the names of both the static function and CaseParsable functions feel right? I like firstMatchingCase although I'm not sure if it completely conveys the behaviour (that it works on the prefix of the input). I feel like enumRawValue could be named better.
  • Should this be further optimised to use UTF8 strings instead of Substring?
lukeredpath
lukeredpath

@victorpimentel I'm pretty snowed under with work so please do feel free to take the ball and run with this. Take whatever you need from this PR if you need anything.

Jan
6
3 weeks ago
push

lukeredpath push lukeredpath/tca-navigation-demo

lukeredpath
lukeredpath

Import workaround to broken NavigationLink transition.

lukeredpath
lukeredpath
lukeredpath
lukeredpath

commit sha: 43e936c9fc3ae48affaa7271b6b19f90496c6431

push time in 2 weeks ago
Jan
5
3 weeks ago
Dec
31
3 weeks ago
Activity icon
issue

lukeredpath issue comment lukeredpath/swift-responsive-textfield

lukeredpath
lukeredpath

Please add a way to manually set the cursor position in the textfield

lukeredpath
lukeredpath
Activity icon
issue

lukeredpath issue comment lukeredpath/swift-responsive-textfield

lukeredpath
lukeredpath

Please add support for LocalizedStringKey

lukeredpath
lukeredpath

Sorry, but you've not included enough information for this to be an actionable issue.

Dec
24
1 month ago
Dec
21
1 month ago
push

lukeredpath push lukeredpath/AdventOfCode2021

lukeredpath
lukeredpath
lukeredpath
lukeredpath

A possibly working but takes forever to complete solution to part 2.

commit sha: dbd4004faadfe71e2f8d7c0775edede67f7df4fa

push time in 1 month ago
push

lukeredpath push lukeredpath/AdventOfCode2021

lukeredpath
lukeredpath
lukeredpath
lukeredpath

Account for bit zero being lit when padding.

lukeredpath
lukeredpath

commit sha: aab26f527e5d640c2edf66c81818af33cb6abb13

push time in 1 month ago
Dec
18
1 month ago
push

lukeredpath push lukeredpath/AdventOfCode2021

lukeredpath
lukeredpath

Day 18 - basic types and operationrs.

lukeredpath
lukeredpath

commit sha: d0c7c4c68de4b03d593ac446829c04949ec6b78b

push time in 1 month ago
Dec
16
1 month ago
Previous