Skip to content

Instantly share code, notes, and snippets.

@loganwright
loganwright / probability.swift
Last active June 24, 2021 23:56
binary-cards-probability
// setup
enum Value: String, CaseIterable, Equatable {
case ace,
two,
three,
four,
five,
six,
seven,
@loganwright
loganwright / dontencode.swift
Created May 7, 2020 13:02
Swift Encodable Dont Encode
@propertyWrapper
struct DontEncode<T: Codable> {
var wrappedValue: T
}
extension DontEncode: Codable {
init(from decoder: Decoder) throws {
self.wrappedValue = try T(from: decoder)
}
@loganwright
loganwright / vapor-three.md
Last active July 21, 2017 17:29
Vapor 3.0 - Swift 4 Checklist

Bits

  • MacOS (07-10)
  • Linux (07-20 | 16.04)

Debugging

  • MacOS (07-10)
  • Linux (07-20 | 16.04)
@loganwright
loganwright / diff.md
Last active April 24, 2017 14:18
Vapor API Diff -- 1.5.15 | 2.0.0-beta.18

Stable API...

==(_:_:)
Abort.metadata
Abort.status
AbortError
Accept
Accept.init(mediaType:preference:)
Accept.mediaType

Enum Case Name

SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_INTERFACE
const char *swift_EnumCaseName(OpaqueValue *value, const Metadata *type) {
  // Build a magic mirror. Unconditionally destroy the value at the end.
  const Metadata *mirrorType;
  const OpaqueValue *cMirrorValue;
  std::tie(mirrorType, cMirrorValue) = unwrapExistential(type, value);
@loganwright
loganwright / docker.md
Last active April 30, 2017 02:56
Docker

Dockerfile

FROM ibmcom/swift-ubuntu:latest

# Install Vapor Toolbox
RUN curl -sL toolbox.vapor.sh | bash

# Set work dir to /vapor
WORKDIR /vapor
@loganwright
loganwright / Fail-0.md
Last active August 31, 2016 01:56
libre
Compile CLibreSSL posix_win.c
Compile CLibreSSL v3_ia5.c
Compile CLibreSSL v3_bcons.c
Compile CLibreSSL sha1_one.c
Compile CLibreSSL ncbc_enc.c
Compile CLibreSSL bs_ber.c
Compile CLibreSSL ocsp_ext.c
Compile CLibreSSL d1_enc.c
Compile CLibreSSL v3_int.c
public final class HTML: Tag {
public let name = "html"
public func shouldRender(
stem: Stem,
context: Context,
tagTemplate: TagTemplate,
arguments: [Argument], value: Any?) -> Bool {
return true
}
@loganwright
loganwright / Queue.swift
Last active August 14, 2016 00:43
Possible Thread Queue
public class Queue {
private var strand: Strand! = nil
private var queue: [Strand.Closure] = []
private let lock = Lock()
public init(_ operation: Strand.Closure? = nil) throws {
if let operation = operation { queue.append(operation) }
strand = try Strand { [weak self] in
while let welf = self {
@loganwright
loganwright / renaming.md
Last active August 4, 2016 19:29
Vapor Renaming
  • node
  • core - 0.3
  • swift
  • tls - 0.4
  • sqlite-driver
  • path-indexable - 0.3
  • polymorphic - 0.3
  • dashboard-example
  • website
  • postgresql-provider