Skip to content

Instantly share code, notes, and snippets.

View lukesutton's full-sized avatar

Luke Matthew Sutton lukesutton

View GitHub Profile
Warden::Manager.serialize_into_session{|user| user.id }
Warden::Manager.serialize_from_session{|id| User.get(id) }
Warden::Manager.before_failure do |env,opts|
# Sinatra is very sensitive to the request method
# since authentication could fail on any type of method, we need
# to set it for the failure app so it is routed to the correct block
env['REQUEST_METHOD'] = "POST"
end
@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

A small sketch for a composable validation library.

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:

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> {