Skip to content

Instantly share code, notes, and snippets.

View lukesutton's full-sized avatar

Luke Matthew Sutton lukesutton

View GitHub Profile
@lukesutton
lukesutton / git
Created September 3, 2019 04:59
Nu Shell examples
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
protocol Cancellable {}
protocol Billable {}
struct Initial: Cancellable {}
struct Placed: Cancellable, Billable {}
struct Billed: Cancellable {}
struct Packed: Cancellable, Billable {}
struct Shipped {}
struct LostInTransit {}
struct DamagedInTransit {}
enum JSON {
case array([JSON])
case object([String: JSON])
case number(Int)
case string(String)
case bool(Bool)
}
extension JSON: ExpressibleByIntegerLiteral {
init(integerLiteral: Int) {

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:

A small sketch for a composable validation library.

struct File {}
struct Landscape {
let parents: FileList
let children: FileList
}
struct FileList {
fileprivate let all: Array<File>
fileprivate let before: ArraySlice<File>
struct StatusSummary {
let items: [Item]
enum Staging {
case staged
case unstaged
case unknown
}
enum Status {
struct Property<N> {
typealias N = N
func toPropertyList() -> PropertyList<N> {
return PropertyList<N>(properties: [self])
}
}
struct PropertyList<N>: PropertyListConvertible {
typealias N = N
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> {
// authentication
// client/account specific info
// urls
// data format transformations; flattening etc
// declarative data transform
// - flatten
// - rename
// - convert
// - renaming
// - blacklist/whitelist