Skip to content

Instantly share code, notes, and snippets.

View ducito's full-sized avatar
🏠
Working from home

Duc Nguyen ducito

🏠
Working from home
View GitHub Profile
@ducito
ducito / Switch.swift
Created January 29, 2019 07:09 — forked from nathantannar4/Switch.swift
Re-Engineering UISwitch
//
// Switch.swift
// Re-Engineering UISwitch
//
// Created by Nathan Tannar on 15/12/18.
// Copyright © 2018 Nathan Tannar. All rights reserved.
//
import UIKit
private var shadowLayer: CAShapeLayer!
private var cornerRadius: CGFloat = 25.0
private var fillColor: UIColor = .blue // the color applied to the shadowLayer, rather than the view's backgroundColor
override func layoutSubviews() {
super.layoutSubviews()
if shadowLayer == nil {
shadowLayer = CAShapeLayer()
shadowLayer.path = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).cgPath
shadowLayer.fillColor = fillColor.cgColor
/*
Example of how to create a view that has rounded corners and a shadow.
These cannot be on the same layer because setting the corner radius requires masksToBounds = true.
When it's true, the shadow is clipped.
It's possible to add sublayers and set their path with a UIBezierPath(roundedRect...), but this becomes difficult when using AutoLayout.
Instead, we a containerView for the cornerRadius and the current view for the shadow.
All subviews should just be added and constrained to the containerView
*/
import UIKit
@ducito
ducito / ssh.md
Last active August 13, 2018 03:41
SSH with multiple accounts

3 steps:

  • Create multi ssh key
  • Add config key
  • Change host to using the right key

Step 1: generate ssh key. Ex:

ssh-keygen -t rsa -f ~/.ssh/key1 -C “account1@gmail.com" ssh-keygen -t rsa -f ~/.ssh/key2 -C "account2@gmail.com"

# ===|| BEGIN EXPORT ||===
export PATH=/usr/local/bin:$PATH
export ANDROID_NDK="/Users/`whoami`/Library/Android/sdk/ndk-bundle"
export PATH="$HOME/Library/Android/sdk/tools:$PATH"
export PATH="$HOME/Library/Android/sdk/platform-tools:$PATH"
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
# ===|| END EXPORT ||===
[core]
excludesfile = /Users/`whoami`/.gitignore_global
[difftool "sourcetree"]
cmd = opendiff \"$LOCAL\" \"$REMOTE\"
path =
[mergetool "sourcetree"]
cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
trustExitCode = true
[user]
email = ngocducdev@gmail.com
@ducito
ducito / UserDefaults.swift
Last active March 12, 2018 06:46
Store and retrieve an object in UserDefaults
import Foundation
struct MyStruct: Codable {
let name: String
let isActive: Bool
}
extension UserDefaults {
private struct Keys {
@ducito
ducito / iterm2-solarized.md
Created December 28, 2017 03:41 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)

Default

Default

Powerlevel9k

Powerlevel9k

@ducito
ducito / iterm2-solarized.md
Created December 28, 2017 03:41 — forked from andyyou/iterm2-solarized.md
iTerm2 + oh my zsh + solarized + Meslo powerline font (OSX)

Solarized

@ducito
ducito / FRP iOS Learning resources.md
Created January 13, 2016 13:54 — forked from JaviLorbada/FRP iOS Learning resources.md
The best FRP iOS resources.

Videos