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
extension Bundle { | |
func decode<T: Decodable>(_ type: T.Type, from file: String, dateDecodingStrategy: JSONDecoder.DateDecodingStrategy = .deferredToDate, keyDecodingStrategy: JSONDecoder.KeyDecodingStrategy = .useDefaultKeys) -> T { | |
guard let url = self.url(forResource: file, withExtension: nil) else { | |
fatalError("Failed to locate \(file) in bundle.") | |
} | |
guard let data = try? Data(contentsOf: url) else { | |
fatalError("Failed to load \(file) from bundle.") | |
} |
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
import SwiftUI | |
struct BackgroundBlob: View { | |
@State private var rotationAmount = 0.0 | |
let alignment: Alignment = [.topLeading, .topTrailing, .bottomLeading, .bottomTrailing].randomElement()! | |
let color: Color = [.blue, .cyan, .indigo, .mint, .purple, .teal].randomElement()! | |
var body: some View { | |
Ellipse() | |
.fill(color) |
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 Endpoint<T: Decodable> { | |
var path: String | |
var type: T.Type | |
var method = HTTPMethod.get | |
var headers = [String: String]() | |
var keyPath: String? | |
} | |
extension Endpoint where T == Array<News> { | |
static let headlines = Endpoint(path: "api/users", type: Array<User>.self, keyPath: "data") |
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
class Debouncer<T>: ObservableObject { | |
@Published var input: T | |
@Published var output: T | |
private var debounce: AnyCancellable? | |
init(initialValue: T, delay: Double = 1) { | |
self.input = initialValue | |
self.output = initialValue | |
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
import Combine | |
import Foundation | |
@propertyWrapper @dynamicMemberLookup | |
class DebouncedObservedObject<Wrapped: ObservableObject>: ObservableObject { | |
var wrappedValue: Wrapped | |
private var subscription: AnyCancellable? | |
init(wrappedValue: Wrapped, delay: Double = 1) { | |
self.wrappedValue = wrappedValue |
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
import { | |
AnimatePresence, | |
motion, | |
useScroll, | |
useTransform, | |
} from "framer-motion"; | |
import { useEffect, useRef, useState } from "react"; | |
export default function HomePage() { | |
const stopAmount = 8; |
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
// some credit for the base structure goes to Jacob Ebey who implemented a similar cache using redis (see: https://github.com/jacob-ebey/remix-ecommerce/tree/main/app) | |
interface RequestResponseCache { | |
(request: Request, maxAgeSeconds: number): Promise<Response>; | |
} | |
const YEAR_AGE = 31556926 | |
// a small hash function to hash a string using the worker compatible crypto engine | |
async function sha256(message: string) { |
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
stages: | |
- build | |
- prepare | |
- deploy | |
build: | |
stage: build | |
image: node:12 | |
environment: | |
name: stage |
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
# If you come from bash you might have to change your $PATH. | |
# export PATH=$HOME/bin:/usr/local/bin:$PATH | |
# Path to your oh-my-zsh installation. | |
export ZSH="/Users/lennart/.oh-my-zsh" | |
# Set name of the theme to load --- if set to "random", it will | |
# load a random theme each time oh-my-zsh is loaded, in which case, | |
# to know which specific one was loaded, run: echo $RANDOM_THEME | |
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes |
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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
NewerOlder