Skip to content

Instantly share code, notes, and snippets.

Working from home

Eric Lewis ericlewis

Working from home
Block or report user

Report or block ericlewis

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
ericlewis / ew.swift
Created Dec 5, 2019
Bluetooth manager for Bangle.js devices
View ew.swift
import CoreBluetooth
protocol ManagerDelegate: AnyObject {
func connected()
func disconnected()
class BluetoothManager: NSObject, CBCentralManagerDelegate, CBPeripheralDelegate {
var centralManager: CBCentralManager!
View example.swift
class Store: ObservableObject {
@Published var id: String? = nil
init() {
id = UserDefaults.standard.string(forKey: "key")
let _ = $id.sink {
UserDefaults.standard.set(id, forKey: "key")
View hackmonster3000.swift
import Foundation
import XcodeGenKit
import ProjectSpec
import XcodeProj
import PathKit
import Files
import SwiftSyntax
enum Errors: Error {
case MainNotModified
ericlewis / HList.swift
Created Oct 25, 2019
"horizontal" list in SwiftUI
View HList.swift
import SwiftUI
extension Int: Identifiable {
public var id: Self {
struct HList<C: RandomAccessCollection, V: View>: View where C.Element: Identifiable {
var data: C
View parser.swift
class Page {
var layers: [Layer] = []
init?(data: Data) {
let header = String(bytes: data[0...32], encoding: .utf8)!.last!
let input = InputStream(data: data[43...])
ericlewis / ContextMenyu.swift
Created Sep 19, 2019
this is some real icky code, not for production use. experiment only.
View ContextMenyu.swift
// ContentView.swift
// ContextMenyu
// Created by Eric Lewis on 9/19/19.
// Copyright © 2019 Eric Lewis, Inc. All rights reserved.
import SwiftUI
ericlewis / tinyotp.swift
Last active Sep 18, 2019
A tiny pure swift implementation of HOTP & TOTP
View tinyotp.swift
import Foundation
import CryptoKit
protocol PasswordProtocol {
var name: String {get}
var issuer: String? {get}
var image: URL? {get}
var generator: GeneratorProtocol {get}
ericlewis / reswift+swiftui.swift
Last active Sep 17, 2019
Example of using ReSwift with SwiftUI
View reswift+swiftui.swift
import SwiftUI
import ReSwift
// MARK: ReSwift Example Setup
struct AppState: StateType {
var counter: Int = 0
struct CounterActionIncrease: Action {}
View gist:3ba58abb7a0ebeb65db3dabde8a7b217
class ExampleViewManager: RCTViewManager {
override func view() -> UIView! {
let scratchyView = ScratchyView()
scratchyView.delegate = self
return scratchyView
extension ExampleViewManager: ScratchyDelegate {
View Search.swift
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 {
You can’t perform that action at this time.