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 { useEffect, useRef, useState } from 'react'; | |
interface ElementSize<T extends HTMLElement> extends Size { | |
ref: React.RefObject<T>; | |
} | |
interface Size { | |
width: number; | |
height: number; | |
} |
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
#!/bin/bash | |
yum -y install \ | |
git \ | |
gcc-c++ \ | |
libcurl-devel \ | |
libedit-devel \ | |
libuuid-devel \ | |
libxml2-devel \ | |
ncurses-devel \ |
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 ContentView: View { | |
@State private var leftCounter = 1 | |
@State private var rightCounter = 1 | |
var body: some View { | |
VStack(spacing: 10) { | |
HStack { | |
Text("\(leftCounter)") |
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(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *) | |
private func stringFromDateStyle(storage: Any) -> String? { | |
let dateStyleChildren = Array(Mirror(reflecting: storage).children) | |
guard dateStyleChildren.count == 2, let text = dateStyleChildren[0].value as? Text else { | |
return nil | |
} | |
let textStorage = Array(Mirror(reflecting: text).children)[0].value // Text.Storage | |
let dateTextStorage = Array(Mirror(reflecting: textStorage).children)[0].value | |
guard "\(type(of: dateTextStorage))" == "DateTextStorage" else { |
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 Foundation | |
import Kingfisher | |
final class ImageLoader { | |
private let imageCache: ImageCache | |
init() throws { | |
self.imageCache = try Self.loadImageCache() | |
} |
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
// Created by Dalton Claybrook on 8/1/23. | |
import Foundation | |
struct Backoff { | |
enum RetryPolicy { | |
case indefinite | |
case maxAttempts(Int) | |
} |
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
.container { | |
position: relative; | |
display: flex; | |
flex-direction: column; | |
gap: 0px; | |
aspect-ratio: 1.9; | |
} | |
.stripe { | |
flex-basis: 0; |
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
extern crate proc_macro; | |
use proc_macro::TokenStream; | |
use syn::parse_macro_input; | |
use quote::quote; | |
use regex::Regex; | |
#[proc_macro] | |
pub fn make_url(_item: TokenStream) -> TokenStream { | |
let input = parse_macro_input!(_item as syn::LitStr); | |
let url_regex = Regex::new(r"^(\w+)://([\w-]+(?:\.[\w-]+)*)((?:/[\w-]+)*)?(\?[\w\-=&]+)?$").unwrap(); |
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
typealias Roll = Int | |
typealias Score = Int | |
enum FrameAttempt { | |
case strike | |
case spare(first: Roll) | |
case open(first: Roll, second: Roll) | |
case tenth(first: Roll, second: Roll, third: Roll?) | |
case inProgress(first: Roll, second: Roll?) | |
} |
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 Foundation | |
/// An Equatable container for storing and accessing just the attributes of an NSAttributedString without | |
/// caring about the string itself. | |
struct TextAttributes: Equatable { | |
private var storage = NSMutableAttributedString(string: "") | |
mutating func setAttributes(_ attributes: [NSAttributedString.Key: Any], range: NSRange) { | |
preserveUniqueReferenceToStorageIfNecessary() | |
extendStringRangeIfNecessary(range: range) |
NewerOlder