Skip to content

Instantly share code, notes, and snippets.

Göksel Köksal gokselkoksal

Block or report user

Report or block gokselkoksal

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@gokselkoksal
gokselkoksal / ToggleFnKeys.scpt
Last active Sep 27, 2015
AppleScript to toggle Fn key (F1, F2, etc.) behaviour.
View ToggleFnKeys.scpt
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
View Property.swift
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) }
}
View UsingChannels-Delegation-Definition.swift
enum Theme: String {
case light, dark
}
protocol UserSettingsDelegate {
func themeDidChange(_ theme: Theme)
}
class UserSettings {
View UsingChannels-NotificationCenter-Definition.swift
enum Theme: String {
case light, dark
}
class UserSettings {
static let shared = UserSettings(notificationCenter: .default)
let notificationCenter: NotificationCenter
var theme: Theme = .light {
View BlurringTheLines-MVVM-3.swift
protocol MovieListView: MovieListPresenterDelegate {
private var presenter: MovieListPresenter
func didTapOnReload()
func didTapOnMovie(at index: Int)
}
protocol MovieListPresenterDelegate {
func updateWithMoviePresentations(_ movies: [MoviePresentation])
}
View BlurringTheLines-MVVM-2.swift
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])
}
View BlurringTheLines-MVVM-1.swift
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)
View JSONWars-Codable.swift
extension Place {
enum CodingKeys: String, CodingKey {
case name = "placeName"
case lat
case lon
case dateAdded
case info
}
View JSONWars-UnboxWrap.swift
extension Place: Unboxable {
static let dateAddedFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "YYYY-mm-dd"
return formatter
}()
init(unboxer: Unboxer) throws {
name = try unboxer.unbox(key: "placeName")
@gokselkoksal
gokselkoksal / Channel.swift
Last active Jun 1, 2018
Channel implementation
View Channel.swift
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
You can’t perform that action at this time.