Skip to content

Instantly share code, notes, and snippets.

View ericlewis's full-sized avatar

Eric Lewis ericlewis

View GitHub Profile
@propertyWrapper
public struct UserDefault<T>: UserDefaultSpec {
let key: String
let defaultValue: T
public init(_ key: String, defaultValue: T) {
self.key = key
self.defaultValue = defaultValue
}
### Keybase proof
I hereby claim:
* I am ericlewis on github.
* I am ericlewis (https://keybase.io/ericlewis) on keybase.
* I have a public key ASBzIjHMyqm5H8e3230zlAxaBzQMVO1pSYwnw0a_TeEYYgo
To claim this, I am signing this object:
const { gql } = require("apollo-server");
const typeDefs = gql`
type PageInfo {
hasNextPage: Boolean
}
type ArtistEdge {
node: Artist
}
@ericlewis
ericlewis / CoreDataList.swift
Created August 8, 2019 18:46
Demonstration of using Core Data with SwiftUI
//
// ContentView.swift
// CoreDataSwiftUISample
//
// Created by Eric Lewis on 8/8/19.
// Copyright © 2019 Eric Lewis, Inc. All rights reserved.
//
import SwiftUI
import CoreData
import SwiftUI
struct SearchNavigationView<Content: View>: UIViewControllerRepresentable {
@Binding var searchText: String
@Binding var scope: Int
var showScope: Bool = false
var content: () -> Content
func makeCoordinator() -> Coordinator {
Coordinator(self)
@objc(ExampleViewManager)
class ExampleViewManager: RCTViewManager {
override func view() -> UIView! {
let scratchyView = ScratchyView()
scratchyView.delegate = self
return scratchyView
}
}
extension ExampleViewManager: ScratchyDelegate {
@ericlewis
ericlewis / reswift+swiftui.swift
Last active September 17, 2019 04:15
Example of using ReSwift with SwiftUI
import SwiftUI
import ReSwift
// MARK: ReSwift Example Setup
struct AppState: StateType {
var counter: Int = 0
}
struct CounterActionIncrease: Action {}
@ericlewis
ericlewis / tinyotp.swift
Last active July 29, 2023 11:31
A tiny pure swift implementation of HOTP & TOTP
import Foundation
import CryptoKit
protocol PasswordProtocol {
var name: String {get}
var issuer: String? {get}
var image: URL? {get}
var generator: GeneratorProtocol {get}
}
@ericlewis
ericlewis / ContextMenyu.swift
Created September 19, 2019 21:28
this is some real icky code, not for production use. experiment only.
//
// ContentView.swift
// ContextMenyu
//
// Created by Eric Lewis on 9/19/19.
// Copyright © 2019 Eric Lewis, Inc. All rights reserved.
//
import SwiftUI
class Page {
var layers: [Layer] = []
init?(data: Data) {
let header = String(bytes: data[0...32], encoding: .utf8)!.last!
let input = InputStream(data: data[43...])
input.open()