Skip to content

Instantly share code, notes, and snippets.

View vnsam's full-sized avatar
🎯
Focusing

DispatchQ vnsam

🎯
Focusing
View GitHub Profile
# vim:ft=zsh ts=2 sw=2 sts=2
#
# agnoster's Theme - https://gist.github.com/3712874
# A Powerline-inspired theme for ZSH
#
# # README
#
# In order for this theme to render correctly, you will need a
# [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts).
# Make sure you have a recent version: the code points that Powerline
@vnsam
vnsam / App.Swift
Created July 30, 2021 13:44
Injection ||| Setup Code
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
@vnsam
vnsam / injection_setup.swift
Created July 29, 2021 07:30
Injection III setup for SwiftUI
// SwiftUI Preview in Xcode is unreliabale and slow. So I started using InjectionIII plugin for previewing.
// AppDelegate setup
import SwiftUI
class InjectedAppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
#if DEBUG
var injectionBundlePath = "/Applications/InjectionIII.app/Contents/Resources"
#if targetEnvironment(macCatalyst)
injectionBundlePath = "\(injectionBundlePath)/macOSInjection.bundle"
@vnsam
vnsam / Bindable.swift
Created January 14, 2020 04:11
A simple implementation of one way binding of property in Swift.
class Bindable<Value> {
typealias Binder = (Value) -> Void
var binder: Binder?
var value: Value {
didSet {
DispatchQueue.main.async { [weak self] in
guard let self = self else {
return
@vnsam
vnsam / Duration.swift
Created January 14, 2020 03:15
Measure Swift Code Running Time
func duration(_ block: () -> Void) {
let startTime = CFAbsoluteTimeGetCurrent()
block()
let timeElapsed = CFAbsoluteTimeGetCurrent() - startTime
print(timeElapsed)
}
@vnsam
vnsam / bash_alias_sublime_text
Created May 19, 2018 13:28
Bash alias function for opening supported files in Sublime Text
openInSublime() {
open -a "Sublime Text" $1
}
@vnsam
vnsam / Timer+Background.swift
Last active February 25, 2019 16:05
Timer - App background support
import Foundation
extension Timer {
static func scheduleTimerEnablingBackground(timeInterval: TimeInterval, target: Any,
selector: Selector, userInfo: Any?,
repeats: Bool) -> Timer {
// Enable background expiration
UIApplication.shared.beginBackgroundTask(expirationHandler: nil)
let timer = Timer.scheduledTimer(timeInterval: timeInterval,
@vnsam
vnsam / gist:187be13c408b291f9b9c0a28c72fb7ff
Created October 10, 2017 13:21
Pro version key for Beyond Compare - v4.2.3.22587
This can be used in Mac by using following trick:
Open trial.key at path: /Applications/Beyond\ Compare.app/Contents/Resources/trial.key
Replace content of trial.key with:
--- BEGIN LICENSE KEY ---
H1bJTd2SauPv5Garuaq0Ig43uqq5NJOEw94wxdZTpU-pFB9GmyPk677gJ
vC1Ro6sbAvKR4pVwtxdCfuoZDb6hJ5bVQKqlfihJfSYZt-xVrVU27+0Ja
hFbqTmYskatMTgPyjvv99CF2Te8ec+Ys2SPxyZAF0YwOCNOWmsyqN5y9t
q2Kw2pjoiDs5gIH-uw5U49JzOB6otS7kThBJE-H9A76u4uUvR8DKb+VcB
rWu5qSJGEnbsXNfJdq5L2D8QgRdV-sXHp2A-7j1X2n4WIISvU1V9koIyS