Skip to content

Instantly share code, notes, and snippets.

View bubudrc's full-sized avatar

Marcelo Perretta bubudrc

View GitHub Profile
@vzsg
vzsg / 1_DynamicQuery.swift
Last active December 10, 2021 14:51
Dynamic Query Support for Vapor 3
import Foundation
import Fluent
protocol DynamicQueryable {
static func dynamicMapping<DB: Database, QB: QueryBuilder<DB, Self>>() -> [String: (DynamicFilter, QB) throws -> QB]
}
protocol DynamicSortable {
static var dynamicFieldMapping: [String: FluentProperty] { get }
}
@vzsg
vzsg / 1_JSONifyTag.swift
Last active November 13, 2024 17:59
Custom Leaf tag for printing anything in the context as JSON (Vapor 4)
import LeafKit
final class JSONifyTag: UnsafeUnescapedLeafTag {
func render(_ ctx: LeafContext) throws -> LeafData {
guard let param = ctx.parameters.first else {
throw "no parameter provided to JSONify"
}
return LeafData.string(param.jsonString)
}
//Import Javascript core
import JavaScriptCore
//[...]
//Get the JS Context
let context = JSContext()!
//write your function in javascript and feed it to context
context.evaluateScript(#"""
@Chronos2500
Chronos2500 / MarqueeLabel-Minimal.swift
Created May 13, 2025 15:19
MarqueeLabel Please be fully aware that these use Private APIs.
let label = UILabel()
label.text = "Swift is a modern, intuitive programming language crafted for all Apple platforms."
label.setValue(true, forKey: "marqueeEnabled")
label.setValue(true, forKey: "marqueeRunning")
label.setValue(0, forKey: "marqueeRepeatCount")
@bubudrc
bubudrc / MarqueeLabel-Minimal.swift
Created May 13, 2025 17:25 — forked from Chronos2500/MarqueeLabel-Minimal.swift
MarqueeLabel Please be fully aware that these use Private APIs.
let label = UILabel()
label.text = "Swift is a modern, intuitive programming language crafted for all Apple platforms."
label.setValue(true, forKey: "marqueeEnabled")
label.setValue(true, forKey: "marqueeRunning")
label.setValue(0, forKey: "marqueeRepeatCount")