Skip to content

Instantly share code, notes, and snippets.

@chungbkhn
chungbkhn / Box.swift
Last active January 22, 2019 07:03
Binding in Swift
import UIKit
class Box<T> {
typealias Listener = (T) -> Void
private var listener: Listener?
private var dispatchThread: DispatchQueue = DispatchQueue.main
var value: T {
didSet {
dispatchThread.async { [weak self] in
@chungbkhn
chungbkhn / script.sh
Created December 2, 2018 15:19
Bash script for auto click on Mac OS with https://github.com/BlueM/cliclick
#!/bin/bash
cliclick c:1295,604
# COUNTER=0
# while [ $COUNTER -lt 10 ]; do
# let COUNTER=COUNTER+1
# cliclick c:1295,604 w:200 c:1298,679 w:12000 c:1225,553 w:200 c:1225,553 w:200
# done
while [ 1 ]; do
cliclick c:1295,604 w:200 c:1298,679 w:12000 c:1225,553 w:200 c:1225,553 w:200
done
@chungbkhn
chungbkhn / NestedProtocol.swift
Last active December 7, 2018 17:22
Nested protocol in swift
import Foundation
// Declare protocol
protocol EXModelExampleProtocol {}
// Namespace Model
enum Model {}
// Make alias for your protocol
extension Model {
@chungbkhn
chungbkhn / Namespace.swift
Last active November 24, 2018 08:06
Namespace in Swift
import UIKit
// Module "Model"
enum Model {}
// Static variable in namespace "Model"
extension Model {
static let defaultName = "anyone"
static let defaultPassword = "Awesome"
static let defaultLevel: Account.Level = .basic