Skip to content

Instantly share code, notes, and snippets.

Avatar

Nathan Borror nathanborror

View GitHub Profile
@nathanborror
nathanborror / ContentView.swift
Last active Sep 22, 2020
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 May 23, 2020
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 Feb 11, 2018
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 Jan 30, 2018
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 Dec 2, 2020
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
View index.js
var jwt = require("jsonwebtoken")
var http2 = require("http2")
const ALGORITHM = "ES256"
const APNS_KEY_ID = "YOUR_APNS_KEY_ID"
const TEAM_ID = "YOUR_TEAM_ID"
const BUNDLE_ID = "YOUR_BUNDLE_ID"
const REGISTRATION_ID = "YOUR_DEVICE_PUSH_TOKEN"
const CERT =
@nathanborror
nathanborror / index.js
Last active Nov 27, 2018
Slack webhook Cloud Functions for Google Cloud Container Builder
View index.js
const IncomingWebhook = require("@slack/client").IncomingWebhook
const SLACK_WEBHOOK_URL = "SLACK_WEBHOOK_URL"
const webhook = new IncomingWebhook(SLACK_WEBHOOK_URL)
// subscribe is the main function called by Cloud Functions.
module.exports.slackSubscribe = (event, callback) => {
const build = eventToBuild(event.data.data)
// Skip if the current status is not in the status list.
View ledger.go
package ledger
import (
"encoding/json"
"time"
"github.com/jmoiron/sqlx"
"github.com/jmoiron/sqlx/types"
uuid "github.com/satori/go.uuid"
)
You can’t perform that action at this time.