Skip to content

Instantly share code, notes, and snippets.

View bubudrc's full-sized avatar

Marcelo Perretta bubudrc

View GitHub Profile
@bubudrc
bubudrc / Image+Data.swift
Created January 30, 2023 15:00 — forked from BrentMifsud/Image+Data.swift
SwiftUI Image from data
import Foundation
import SwiftUI
#if canImport(UIKit)
import UIKit
#elseif canImport(AppKit)
import AppKit
#endif
extension Image {
/// Initializes a SwiftUI `Image` from data.
@bubudrc
bubudrc / Hashes.swift
Last active February 3, 2023 19:07
HMAC Using SHA1 with Secret Key (Works for other HMAC algorithms) for CryptoKit
import Foundation
import CryptoKit
extension String {
func hmacUsingSHA1(_ secretString: String) -> String {
let key = SymmetricKey(data: secretString.data(using: .utf8)!)
let signature = HMAC<Insecure.SHA1>.authenticationCode(for: self.data(using: .utf8)!, using: key)
return Data(signature).map { String(format: "%02hhx", $0) }.joined()
@bubudrc
bubudrc / SchedulerPlayground.swift
Created June 25, 2023 06:02 — forked from natanrolnik/SchedulerPlayground.swift
A playground for a small wrapper that manages multiple DispatchWorkItems
import Foundation
import PlaygroundSupport
typealias DispatcherIdentifier = String
class Dispatcher {
private var items = [DispatcherIdentifier: DispatchWorkItem]()
private let queue: DispatchQueue
@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")