Skip to content

Instantly share code, notes, and snippets.

Avatar

Nathan Borror nathanborror

View GitHub Profile
View macos-defaults.md

Key repeat

defaults write -g InitialKeyRepeat -int 10 # normal minimum is 15 (225 ms)
defaults write -g KeyRepeat -int 1 # normal minimum is 2 (30 ms)

Requires restart.

Hide desktop

@nathanborror
nathanborror / gcloud-run.md
Last active May 31, 2022 15:50
How to setup a new Go project using Google Cloud Run and Cloud SQL.
View gcloud-run.md

Go Google Cloud

How to setup a new Go project using Google Cloud Run and Cloud SQL.

Setup a new project

Update gcloud and authenticate

$ gcloud components update
$ gcloud auth login
View flip.swift
struct FlippedUpsideDown: ViewModifier {
func body(content: Content) -> some View {
content
.rotationEffect(.radians(.pi))
.scaleEffect(x: -1, y: 1, anchor: .center)
}
}
extension View {
func flipUpsideDown() -> some View {
@nathanborror
nathanborror / ContentView.swift
Last active October 30, 2022 13:26
SwiftUI wrapper around Slack's PanModal (https://github.com/slackhq/PanModal)
View ContentView.swift
import SwiftUI
import PanModal
struct ExampleView: View {
@State var detail: AnyView? = nil
@State var items: [String] = ["Detail 1", "Detail 2", "Detail 3"]
var body: some View {
NavigationView {
View localized-launch-screen.md

iOS Launch Screen

Steps taken to unofficially localize:

  1. Create a new InfoPlist.strings file
  2. Add the following line to that file:
UILaunchStoryboardName = "LaunchScreen";
View AdaptToKeyboard.swift
// https://stackoverflow.com/questions/56716311/how-to-show-complete-list-when-keyboard-is-showing-up-in-swiftui?noredirect=1&lq=1
import SwiftUI
import Combine
struct AdaptToKeyboard: ViewModifier {
@State var currentHeight: CGFloat = 0
func body(content: Content) -> some View {
@nathanborror
nathanborror / playground.swift
Last active January 3, 2023 22:16
Custom UIKit view with child SwiftUI views
View playground.swift
import UIKit
import SwiftUI
import PlaygroundSupport
// CustomParentView is a custom UIKit view. Its Coordinator can be used
// to manage delegates if needed (e.g. UIContextMenuInteractionDelegate).
struct CustomParentView<Content: View>: UIViewRepresentable {
let content: UIView
@nathanborror
nathanborror / sm-2.swift
Last active February 11, 2018 00:13
SM-2 Algorithm
View sm-2.swift
// Based on the SuperMemo 2 Algorithm:
// https://www.supermemo.com/english/ol/sm2.htm
import UIKit
struct Item {
let id: UUID
let prompt: String
let explaination: String
var score: Score
@nathanborror
nathanborror / delay.swift
Created January 30, 2018 18:42
Simulate Slow Connection
View delay.swift
let task = URLSession.shared.dataTask(with: req) { (data, response, error) in
...
}
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(4)) {
task.resume()
}
@nathanborror
nathanborror / instructions.txt
Last active May 17, 2023 00:55
Example Kubernetes setup with Postgres and two Services for serving an API and a static site using Ingress. Also have a CronJob example for kicks.
View instructions.txt
*** Cluster Setup for Google Container Engine ***
0/ Install and configure local gcloud and kubectl: https://cloud.google.com/sdk/docs/
> gcloud components install kubectl
1/ Configure Google Cloud account:
> gcloud config set account YOUR_EMAIL_ADDRESS
> gcloud config set project YOUR_PROJECT_ID
> gcloud config set compute/zone us-west1-a
> gcloud config set container/cluster example