Skip to content

Instantly share code, notes, and snippets.

View StefKors's full-sized avatar
📟

Stef Kors StefKors

📟
View GitHub Profile
//
// ContentView.swift
// AppleLogo
//
// Created by Oskar Groth on 2021-06-17.
//
import SwiftUI
struct ContentView: View {
@sunshinejr
sunshinejr / Debounced.swift
Last active September 20, 2021 09:47
Swift Property wrapper for debouncing values
@propertyWrapper
public final class Debounced<T: Hashable>: BindingConvertible {
public let delay: Double
private var _value: T
private var timer: Timer? = nil
public var wrappedValue: T {
get {
return _value
import SwiftUI
import PlaygroundSupport
struct ContentView: View {
@State var gradientAngle: Double = 0
var colors = [
Color(UIColor.systemRed),
Color(UIColor.systemOrange),
Color(UIColor.systemYellow),
Color(UIColor.systemGreen),
@skullface
skullface / lint-autofix.yml
Created November 19, 2021 03:21
Teensy GitHub Action to autofix linting errors (from the script defined in your package.json) per https://mskelton.medium.com/auto-formatting-code-using-prettier-and-github-actions-ed458f58b7df
name: Lint and autofix
on:
pull_request:
branches: [main]
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
@larsaugustin
larsaugustin / RetroDock.swift
Created May 26, 2021 15:33
A macOS dock replacement with a modernized version of the design used before Yosemite
import SwiftUI
// MARK: - Constants
// Items in the dock: Add any application you’d like to see in here
let items =
[
"file:///Applications/Xcode.app",
"file:///Applications/Safari.app",
"file:///System/Applications/Messages.app",
@Gozala
Gozala / Readme.md
Last active June 8, 2023 07:31
Range hilighting code using getClientRects API

Highlight Selection Ranges

Code here takes a DOM Selection Range instance and creates a highlighting for it by using getClientRects. Approach was inspired by marks although here function attempts to find nearest positioned parent element to the commonAncestorContainer and draw all the highilighting rectangles there, this avoids issues with an overflowing content.

Issues

  • Approach ignores z-index which isn't great as some element might be overlaying the selection in which case it should not appear, but it does if we use high z-index value. If we use low z-index value then some elements (possibly ones containing selection) might end up overlaying selection itself.
  • Rendered selections are scattered all o
export type BaseCountry = {
// the ISO 3166-1 code for the country
code: string
// the name of the country (in english)
name: string
// the raw emoji for the country's flag (can be multiple codepoints)
emoji: string
// the international dialing code for the country (without the `+` prefix or escape codes)
dial_country_code: string
// the regions codes, if any
@chilts
chilts / alexa.js
Created October 30, 2013 09:27
Getting the Alexa top 1 million sites directly from the server, unzipping it, parsing the csv and getting each line as an array.
var request = require('request');
var unzip = require('unzip');
var csv2 = require('csv2');
request.get('http://s3.amazonaws.com/alexa-static/top-1m.csv.zip')
.pipe(unzip.Parse())
.on('entry', function (entry) {
entry.pipe(csv2()).on('data', console.log);
})
;
@chriseidhof
chriseidhof / boilerplate.swift
Last active January 3, 2024 05:54
QuickMacApp
// Run any SwiftUI view as a Mac app.
import Cocoa
import SwiftUI
NSApplication.shared.run {
VStack {
Text("Hello, World")
.padding()
.background(Capsule().fill(Color.blue))
@zats
zats / ContentView.swift
Last active February 17, 2024 10:23
Internal SF Symbols
struct ContentView: View {
var body: some View {
let names = [
["appstore.app.dashed", "buildings.3d", "emoji.chicken.face"],
["person.text.rectangle.and.nfc", "secure.element", "laugh.bubble.tapback.2.he"],
["apple.news", "apple.podcasts.square.stack", "apple.slice"],
]
VStack(spacing: 20) {
Grid(horizontalSpacing: 20, verticalSpacing: 20) {
ForEach(names, id: \.self) { nameRow in