Skip to content

Instantly share code, notes, and snippets.

Avatar

Luke Matthew Sutton lukesutton

View GitHub Profile
@lukesutton
lukesutton / git
Created Sep 3, 2019
Nu Shell examples
View git
echo "$(git log --pretty=format:'%h|%s|%aN|%aE|%aD' -n 10)" | lines | split-column "|" commit subject name email date
git status --porcelain | lines | split-column " " status file
View state-machines.swift
protocol Cancellable {}
protocol Billable {}
struct Initial: Cancellable {}
struct Placed: Cancellable, Billable {}
struct Billed: Cancellable {}
struct Packed: Cancellable, Billable {}
struct Shipped {}
struct LostInTransit {}
struct DamagedInTransit {}
View JSONQuery.swift
enum JSON {
case array([JSON])
case object([String: JSON])
case number(Int)
case string(String)
case bool(Bool)
}
extension JSON: ExpressibleByIntegerLiteral {
init(integerLiteral: Int) {
View keybase.md

Keybase proof

I hereby claim:

  • I am lukesutton on github.
  • I am lukesutton (https://keybase.io/lukesutton) on keybase.
  • I have a public key ASALqKe7LRdQEwJTKp2o0MMVTaBLKa7wctbkXfSdA4TyWQo

To claim this, I am signing this object:

View README.md

A small sketch for a composable validation library.

View file-navigation.swift
struct File {}
struct Landscape {
let parents: FileList
let children: FileList
}
struct FileList {
fileprivate let all: Array<File>
fileprivate let before: ArraySlice<File>
View git-status.swift
struct StatusSummary {
let items: [Item]
enum Staging {
case staged
case unstaged
case unknown
}
enum Status {
View properties.swift
struct Property<N> {
typealias N = N
func toPropertyList() -> PropertyList<N> {
return PropertyList<N>(properties: [self])
}
}
struct PropertyList<N>: PropertyListConvertible {
typealias N = N
View actions.swift
enum ActionResult<R> {
case success(R)
case error(Error)
}
struct Action<Context, Input, Result> {
let run: (Context, Input) -> ActionResult<Result>
}
func + <Context, Input, ResultA, ResultB>(lhs: Action<Context, Input, ResultA>, rhs: Action<Context, ResultA, ResultB>) -> Action<Context, Input, ResultB> {
View transforms.swift
// authentication
// client/account specific info
// urls
// data format transformations; flattening etc
// declarative data transform
// - flatten
// - rename
// - convert
// - renaming
// - blacklist/whitelist
You can’t perform that action at this time.