Skip to content

Instantly share code, notes, and snippets.

View maakcode's full-sized avatar
💭
I may be slow to respond.

MaakCode maakcode

💭
I may be slow to respond.
View GitHub Profile
@maakcode
maakcode / ButtonBackgroundColor.swift
Last active March 24, 2022 23:02
How to set UIButton background color for control state with single dynamic color
import UIKit
extension UIButton {
func setBackgroundColor(_ color: UIColor, for state: State) {
let backgroundImage: UIImage = .dynamicImage(light: .generate(withColor: color.light),
dark: .generate(withColor: color.dark))
setBackgroundImage(backgroundImage, for: state)
}
}
@maakcode
maakcode / Clamped.swift
Created September 6, 2021 21:25
Clamped with Range extension in Swift
import UIKit
import XCTest
import PlaygroundSupport
extension Int {
func clamped(_ range: Range<Self>) -> Self {
if range.contains(self) {
return self
}
@maakcode
maakcode / TimeInterval.swift
Created March 21, 2021 01:32
Composable TimeInterval extensions
extension TimeInterval {
static func milliseconds(_ value: Self) -> Self {
Self(value * 1e-3)
}
static func seconds(_ value: Self) -> Self {
Self(value)
}
static func minutes(_ value: Self) -> Self {
@maakcode
maakcode / keboardSettings
Last active November 6, 2020 05:22
Mac Input Settings
mkdir ~/Library/KeyBindings && vim ~/Library/KeyBindings/DefaultKeyBinding.dict
# DefaultKeyBinding.dict 에 아래의 설정을 붙여넣으세요.
/* ~/Library/KeyBindings/DefaultKeyBinding.Dict
This file remaps the key bindings of a single user on Mac OS X 10.5 to more
closely match default behavior on Windows systems. This makes the Command key
behave like Windows Control key. To use Control instead of Command, either swap
Control and Command in Apple->System Preferences->Keyboard->Modifier Keys...
@maakcode
maakcode / loudnorm.py
Last active June 27, 2020 08:24
Normalizing audio loudness using ffmpeg-python(https://github.com/kkroening/ffmpeg-python)
import ffmpeg
import json
import subprocess
import os
import sys
import time
def loudnorm(name, ext):
singlePass = subprocess.Popen(
(
@maakcode
maakcode / NSBlur.swift
Created May 11, 2020 03:30
Visual Effects View in SwiftUI, AppKit
// Visual Effects View in SwiftUI, AppKit
// cf. https://gist.github.com/edwurtle/98c33bc783eb4761c114fcdcaac8ac71#file-blur-swift
import SwiftUI
struct NSBlur: NSViewRepresentable {
var blendingMode: NSVisualEffectView.BlendingMode = .withinWindow
func makeNSView(context: Context) -> NSVisualEffectView {
let view = NSVisualEffectView()
view.blendingMode = blendingMode
@maakcode
maakcode / hangul.swift
Created December 16, 2019 06:50
Swift Gists
import Cocoa
/*
는/은, 가/이, 야/아, 와/과, 를/을, 다/이다, 으로/로
*/
extension String {
struct KoreanSound {
static let firsts = ["ㄱ", "ㄲ", "ㄴ", "ㄷ", "ㄸ", "ㄹ", "ㅁ", "ㅂ", "ㅃ", "ㅅ", "ㅆ", "ㅇ", "ㅈ", "ㅉ", "ㅊ", "ㅋ", "ㅌ", "ㅍ", "ㅎ"]
static let middles = [ "ㅏ", "ㅐ", "ㅑ", "ㅒ", "ㅓ", "ㅔ", "ㅕ", "ㅖ", "ㅗ", "ㅘ", "ㅙ", "ㅚ", "ㅛ", "ㅜ", "ㅝ", "ㅞ", "ㅟ", "ㅠ", "ㅡ", "ㅢ", "ㅣ" ]
@maakcode
maakcode / atcommand.md
Last active December 10, 2018 03:41
[Arduino] Arduino related #arduino

ATcommand

  • AT: 연결 테스트

    • 응답: OK
  • AT+RMAAD

  • AT+BAUD[n]: 보드레이드 설정, 파라메터 미입력시 현재 설정 표시

    • 응답: +BAUD=[n]
    입력 가능한 n Baud
    1 1200
@maakcode
maakcode / downgrade python3.7 to python3.6.md
Last active December 12, 2018 04:12
[python3] #python3
brew unlink python3
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/e128fa1bce3377de32cbf11bd8e46f7334dfd7a6/Formula/python.rb
brew switch python3.6.5