Skip to content

Instantly share code, notes, and snippets.

View laurenchen0631's full-sized avatar

Lorne Chen laurenchen0631

View GitHub Profile
@laurenchen0631
laurenchen0631 / Canvas.swift
Last active June 17, 2020 09:37
Swiftui Canvas(Parent View)
import SwiftUI
struct CameraCanvas: UIViewRepresentable {
var backgroundColor: UIColor?
let rendererView = UIView()
func makeUIView(context _: Context) -> UIView {
rendererView.backgroundColor = backgroundColor ?? UIColor.black
return rendererView
}
// Based on https://medium.com/@mahmudahsan/how-to-create-checkbox-in-swiftui-ad08e285ab3d
import SwiftUI
struct CheckboxField<Label: View>: View {
@Binding var checked: Bool
let label: Label
let size: CGFloat
let color: Color
@laurenchen0631
laurenchen0631 / CustomTextField.swift
Last active June 22, 2021 18:25
Swiftui CustomTextField
// customized text field based on @Anshuman Singh https://stackoverflow.com/questions/58311022/autofocus-textfield-programmatically-in-swiftui
import SwiftUI
struct CustomTextField: UIViewRepresentable {
class Coordinator: NSObject, UITextFieldDelegate {
@Binding var textInput: String
@Binding var nextResponder: Bool?
@Binding var isResponder: Bool?
var maxLength: Int?
package renderer
import (
"github.com/stretchr/testify/assert"
"reflect"
"testing"
)
type T struct {
Apple int
@laurenchen0631
laurenchen0631 / ConvertStructToMap.go
Last active December 26, 2018 06:41
golang convert struct to map with first letter of key field lowercase
package utils
import (
"reflect"
"unicode"
)
// ConvertStructToMap convert the struct to a map which has key with first lowercase letter.
// It skip the zero value of the struct. If you want keep zero value key, put it in the extra map.
func ConvertStructToMap(s reflect.Value, extraMap ...map[string]interface{}) map[string]interface{} {
@laurenchen0631
laurenchen0631 / Dockerfile
Created December 4, 2015 06:52
Docker ubuntu with Swift
FROM ubuntu:latest
RUN apt-get update && apt-get -y upgrade && apt-get install -y \
git \
zsh \
vim \
wget \
clang \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
@laurenchen0631
laurenchen0631 / Dockerfile
Created December 4, 2015 06:49
Docker Ubuntu with prezto zsh
FROM ubuntu:latest
RUN apt-get update && apt-get -y upgrade && apt-get install -y \
git \
zsh \
vim \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"
COPY ./.zshrc /
@laurenchen0631
laurenchen0631 / openlocationcode.service.js
Last active August 29, 2015 14:27
angular-openlocationcode
// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the 'License');
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an 'AS IS' BASIS,