Skip to content

Instantly share code, notes, and snippets.

View gokselkoksal's full-sized avatar

Göksel Köksal gokselkoksal

View GitHub Profile
@gokselkoksal
gokselkoksal / ToggleFnKeys.scpt
Last active September 27, 2015 13:07
AppleScript to toggle Fn key (F1, F2, etc.) behaviour.
tell application "System Preferences"
set current pane to pane "com.apple.preference.keyboard"
tell application "System Events"
tell tab group 1 of window "Keyboard" of process "System Preferences"
click checkbox "Use all F1, F2, etc. keys as standard function keys"
end tell
end tell
end tell
typealias Property<Value, ID> = GenericProperty<Value, ID, Void>
typealias CollectionProperty<Value, ID> = GenericProperty<Value, ID, CollectionChange>
struct GenericProperty<Value, ID, ChangeInfo> {
private var _value: Value
var value: Value {
get { return _value }
set { set(newValue) }
}
@gokselkoksal
gokselkoksal / SwiftMigrationJustifications.md
Last active April 23, 2020 20:11
SwiftMigrationJustifications

Number of Lines in Swift Files

Might be handy when estimating work.

  1. Open Terminal
  2. cd to your Xcode project
  3. Execute the following when inside your target project:

Number of lines:

@gokselkoksal
gokselkoksal / Channel.swift
Last active September 16, 2022 03:53
Channel implementation
public class Channel<Value> {
private class Subscription {
weak var object: AnyObject?
private let notifyBlock: (Value) -> Void
private let queue: DispatchQueue
var isValid: Bool {
return object != nil
enum Theme: String {
case light, dark
}
protocol UserSettingsDelegate {
func themeDidChange(_ theme: Theme)
}
class UserSettings {
enum Theme: String {
case light, dark
}
class UserSettings {
static let shared = UserSettings(notificationCenter: .default)
let notificationCenter: NotificationCenter
var theme: Theme = .light {
enum Theme: String {
case light, dark
}
class UserSettings {
enum Message {
case didUpdateTheme(Theme)
}
protocol MovieListView: MovieListViewModelDelegate {
private var viewModel: MovieListViewModel
func updateWithMovies(_ movies: [Movie])
func didTapOnReload()
func didTapOnMovie(at index: Int)
func showDetailView(for movie: Movie)
}
protocol MovieListViewModelDelegate: class {
func viewModelDidUpdate(_ model: MovieListViewModel)
protocol MovieListView: MovieListPresenterDelegate {
private var presenter: MovieListPresenter
func didTapOnReload()
func didTapOnMovie(at index: Int)
func showDetailView(for movie: Movie)
}
protocol MovieListPresenterDelegate {
func updateWithMoviePresentations(_ movies: [MoviePresentation])
}
protocol MovieListView: MovieListPresenterDelegate {
private var presenter: MovieListPresenter
func didTapOnReload()
func didTapOnMovie(at index: Int)
}
protocol MovieListPresenterDelegate {
func updateWithMoviePresentations(_ movies: [MoviePresentation])
}