Skip to content

Instantly share code, notes, and snippets.

View daneden's full-sized avatar

Daniel Eden daneden

View GitHub Profile
@daneden
daneden / ContentView.swift
Created January 29, 2024 14:41
SwiftUI app showing how to prevent multiple `WindowGroup` windows
//
// ContentView.swift
// WindowExample
//
// Created by Daniel Eden on 29/01/2024.
//
import SwiftUI
struct ContentView: View {
@daneden
daneden / dabblet.css
Created November 28, 2012 12:37
Twitter
/**
* Twitter
*/
* {
margin: 0;
padding: 0;
box-sizing: border-box;
position: relative;
}
@daneden
daneden / dabblet.css
Created April 22, 2012 11:17
Stacking context demo
/* Stacking context demo */
* {
margin: 0;
padding: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
//
// Color.extension.swift
// Zeitgeist
//
// Created by Daniel Eden on 30/12/2020.
// Copyright © 2020 Daniel Eden. All rights reserved.
//
import Foundation
import SwiftUI
struct Fields {
var userFields: Set<User.Fields>?
var tweetFields: Set<Tweet.Fields>?
}
protocol Fetcher {
// Is there a way to do something like this, where I can specify that the `Fields`
// struct must contain only these member types?
func getTweet(fields: Fields<Tweet.Fields, User.Fields>? = nil) async -> Tweet
func getUser(fields: Fields<User.Fields>? = nil) async -> User
struct User: Codable, Identifiable {
typealias ID = String
let id: ID
let name: String
let username: String
// Assume that items can be optionally set in getUser
var items: UserItems?
}
@daneden
daneden / Instructions.md
Created December 1, 2015 00:25
Remap Caps Lock to Emoji on Mac

How to remap the caps lock key to the emoji selector on Mac

  1. Go to System Preferences -> Keyboard -> Modifier Keys...
  2. Change “Caps Lock” to “No action”
  3. Install Seil
  4. Change the Caps Lock key in Seil to keyCode 80 (F19)
  5. Install Karabiner
  6. Open Karabiner and go to Misc & Uninstall -> Open private.xml
  7. Copy the contents of this gist's example to the XML file and save
  8. In Karabiner, go to Change Keys -> Reload XML

I’m trying to decode two slightly different JSON API responses to the same Codable type, Account. Mapping userResponse.json’s uid to id is trivial, but extracting the nested user is stumping me.

Any suggestions would be greatly appreciated!

@daneden
daneden / dabblet.css
Created June 17, 2012 20:06
<i> Cloud
/* <i> Cloud */
html {
min-height: 100%;
background: linear-gradient(#b4bcbf, #fff);
}
.cloud {
display: inline-block;
background-color: #fff;
import SwiftUI
import Combine
struct HMS {
var h: Int
var m: Int
var s: Int
}
struct ContentView: View {