Skip to content

Instantly share code, notes, and snippets.

View jdmcd's full-sized avatar
💭
Coding 👨🏻‍💻

Jimmy McDermott jdmcd

💭
Coding 👨🏻‍💻
View GitHub Profile
#!/usr/bin/osascript
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Basecamp Assignments
# @raycast.mode silent
# Optional parameters:
# @raycast.icon https://basecamp.com/favicon-32x32.png
// *********** Cacheable Protocols *********** //
protocol Cacheable: Codable {
var expirationDate: Date { get set }
}
protocol CacheableDriver {
func nuke(key: String) -> Future<Void>
func get<C: Codable>(key: String) -> Future<C?>
func set<C: Codable>(key: String, data: C) -> Future<Void>
@jdmcd
jdmcd / AutoContentDecode.swift
Last active April 28, 2020 16:44
A collection of helpers for Vapor 4
// An extension to replicate the same functionality from Vapor 3 with automatic content decoding:
import Foundation
import Vapor
/// A basic, closure-based `Responder`.
struct ContentBasicResponder<C: Content>: Responder {
/// The stored responder closure.
private let closure: (Request, C) throws -> EventLoopFuture<Response>
@jdmcd
jdmcd / GoogleCaptcha.swift
Created April 29, 2018 14:35
Vapor 3 helper for validating Google Recaptchas
import Foundation
import Vapor
struct GoogleCaptcha {
let client: Client
let secretKey: String
private let endpoint = "https://www.google.com/recaptcha/api/siteverify"
func validate(captchaResponse: String) throws -> Future<Bool> {
let requestData = GoogleCaptchaRequest(secret: secretKey, response: captchaResponse)
04957561d6cb13e25840aad8d8fb0ac5d5b9674e443749b1163cc9dea94f14f1cef8ab392f7d08c9ba785caec069ceef3a82c6a6d87750004b1a7127cf2d9587dc
@jdmcd
jdmcd / API.swift
Last active June 19, 2020 07:37
Alamofire + Codable
class API {
static let apiKey = "test"
static let baseUrl = ""
enum Endpoint {
case login
case register
var endpoint: String {
switch self {