This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: ./remove_files.sh /path/to/folder /path/to/input_file.txt | |
# Get the directory and input file from the arguments | |
TARGET_DIR="$1" | |
INPUT_FILE="$2" | |
# Check if the directory exists | |
if [ ! -d "$TARGET_DIR" ]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TitleColorLabel: UILabel { | |
var lightTitleColor: UIColor = .white { didSet { updateTitleColor() }} | |
var darkTitleColor: UIColor = .black { didSet { updateTitleColor() }} | |
override var backgroundColor: UIColor? { | |
didSet { | |
updateTitleColor() | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let center = UNUserNotificationCenter.current() | |
center.delegate = self | |
center.requestAuthorization(options: [.alert, .badge, .sound]) { (granted, error) in | |
if granted { | |
print("Permission granted") | |
let content = UNMutableNotificationContent() | |
content.title = "My title" | |
content.body = "Lots of text" | |
content.sound = UNNotificationSound.default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// KitTemplate.swift | |
// AutoFills | |
// | |
// Created by Cem Olcay on 1/20/24. | |
// | |
import Foundation | |
enum KitTemplate: Int, Codable, CustomStringConvertible, CaseIterable { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WeightedRandom<T> { | |
var elements: [Element] | |
init(elements: [Element] = []) { | |
self.elements = elements | |
} | |
struct Element { | |
let item: T | |
let weight: Double |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func convert<T: FloatingPoint>(value: T, inRange: ClosedRange<T>, toRange: ClosedRange<T>) -> T { | |
let oldRange = inRange.upperBound - inRange.lowerBound | |
let newRange = toRange.upperBound - toRange.lowerBound | |
return (((value - inRange.lowerBound) * newRange) / oldRange) + toRange.lowerBound | |
} | |
/// Variety: [0 - 1]. 0 means no randomisation, 1 means a random value between full range. | |
func variety(value: Double, inRange: ClosedRange<Double>, variety: Double) -> Double { | |
let normalised = inRange == 0...1 ? value : convert(value: value, inRange: inRange, toRange: 0 ... 1) | |
let upper = min(normalised + variety, 1.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// TuringMachine.swift | |
// TuringBud | |
// | |
// Created by Cem Olcay on 3/8/22. | |
// | |
import Foundation | |
class TuringMachine { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Collection where Self.Index == Int { | |
subscript(row: Int, col: Int, colCount: Int) -> Element? { | |
let index = row * colCount + col | |
guard index >= 0, index < count else { return nil } | |
return self[index] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// LiveKnobSwiftUI.swift | |
// ControlBud-SwiftUI | |
// | |
// Created by Cem Olcay on 11/3/21. | |
// | |
import UIKit | |
import SwiftUI | |
import LiveKnob |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// LiveFaderSwiftUI.swift | |
// ControlBud-SwiftUI | |
// | |
// Created by Cem Olcay on 11/4/21. | |
// | |
import UIKit | |
import SwiftUI | |
import LiveFader |
NewerOlder