Skip to content

Instantly share code, notes, and snippets.

@ayaysir
ayaysir / Debounce.swift
Last active December 12, 2022 15:37
Debounce & Throttle 1
import Foundation
class Debounce: DelayWork {
override func run() {
self.workItem?.cancel()
let workItem = DispatchWorkItem { [weak self] in
self?.handler?(Date())
}
@ayaysir
ayaysir / Add_Prefix_To_Search_Window.js
Last active November 16, 2022 05:32
With this code, you'll get a SELECT menu in front of the Google search bar to select a prefix. // 1. install js-injection chrome plugin // 2. in google.com, add this code with select 'use jQuery 3' option
const KEY_LAST_SELECTED = "LAST_SELECTED"
const divText = `
<select id="q-prefix" style="float: left;">
<option>none</option>
<option selected>swift</option>
<option>js</option>
<option>jquery</option>
<option>java</option>
<option>musescore</option>
tell application "Google Chrome" to activate
-- (60*60*5)/5 = 3600
repeat 100000 times
-- space bar double press
if application "Google Chrome" is running then
tell application "System Events" to key code 49
delay 0.4
tell application "System Events" to key code 53
-- tell application "System Events" to click at {1088, 994}
-- tell application "System Events" to click at {1088, 994}
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div id="loading-status">Loading...</div>
//
// ContainerViewController.swift
// Example-ContainerView
//
// Created by yoonbumtae on 2022/09/13.
//
import UIKit
// 2-1: 대리자 프로토콜 작성
-- 로직 X 피아노롤 아래에 있는 상태에서 G#0 노트 클릭 활성화
-- A0(21) ~ C8(108)
set midiNoteNum to 21
tell application "Logic Pro X" to activate
tell application "System Events"
repeat while midiNoteNum ≤ 108
//
// FirebasePractice.swift
//
// Created by yoonbumtae on 2022/06/12.
//
import Foundation
import FirebaseAuth
import FirebaseFirestore
import FirebaseFirestoreSwift
@ayaysir
ayaysir / Array+.Swift
Created June 5, 2022 15:11
makeShuffledArray
//
// Array+.swift
// MusicScale
//
// Created by yoonbumtae on 2022/06/05.
//
import Foundation
enum ShuffleArrayError: Error {
@ayaysir
ayaysir / PhotoAuth.swift
Last active May 8, 2022 15:11
Swift 사진 권한 물어보기
import UIKit
import Photos
// MARK: - 사진 권한 물어보기
private func photoAuth(isCamera: Bool, viewController: UIViewController, completion: @escaping () -> ()) {
// 경고 메시지 작성
let sourceName = isCamera ? "카메라" : "사진 라이브러리"
let notDeterminedAlertTitle = "No Permission Status"
@ayaysir
ayaysir / console.html
Created August 28, 2021 12:01
콘솔 로그(console.log)를 HTML에 표시
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Console Log</title>
</head>
<body>
<pre id="console"></pre>