A small sketch for a composable validation library.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol Cancellable {} | |
protocol Billable {} | |
struct Initial: Cancellable {} | |
struct Placed: Cancellable, Billable {} | |
struct Billed: Cancellable {} | |
struct Packed: Cancellable, Billable {} | |
struct Shipped {} | |
struct LostInTransit {} | |
struct DamagedInTransit {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum JSON { | |
case array([JSON]) | |
case object([String: JSON]) | |
case number(Int) | |
case string(String) | |
case bool(Bool) | |
} | |
extension JSON: ExpressibleByIntegerLiteral { | |
init(integerLiteral: Int) { |
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:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct StatusSummary { | |
let items: [Item] | |
enum Staging { | |
case staged | |
case unstaged | |
case unknown | |
} | |
enum Status { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Property<N> { | |
typealias N = N | |
func toPropertyList() -> PropertyList<N> { | |
return PropertyList<N>(properties: [self]) | |
} | |
} | |
struct PropertyList<N>: PropertyListConvertible { | |
typealias N = N |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> { |
NewerOlder