Skip to content

Instantly share code, notes, and snippets.

View seyhunak's full-sized avatar
🏆
Polyglot Programmer

Seyhun Akyürek seyhunak

🏆
Polyglot Programmer
View GitHub Profile
@seyhunak
seyhunak / DynamicValue.swift
Last active September 6, 2019 11:22
DynamicValue
import Foundation
typealias CompletionHandler = (() -> Void)
class DynamicValue<T> {
var value : T {
didSet {
self.notify()
}
}
@seyhunak
seyhunak / git-clearHistory
Created August 30, 2019 21:25 — forked from stephenhardy/git-clearHistory
Steps to clear out the history of a git/github repository
-- Remove the history from
rm -rf .git
-- recreate the repos from the current content only
git init
git add .
git commit -m "Initial commit"
-- push to the github remote repos ensuring you overwrite history
git remote add origin git@github.com:<YOUR ACCOUNT>/<YOUR REPOS>.git
@seyhunak
seyhunak / web-servers.md
Created December 12, 2017 19:47 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@objc protocol Refreshable
{
/// The refresh control
var refreshControl: UIRefreshControl? { get set }
/// The table view
var tableView: UITableView! { get set }
/// the function to call when the user pulls down to refresh
@objc func handleRefresh(_ sender: Any);
FIRDatabase.database().reference().child("conversations").child(location).observe(.value, with: { (snapshot) in
if(snapshot.childrenCount > 1) {
var removeCount = Int(snapshot.childrenCount) - 1
let enumerator = snapshot.children
while let rest = enumerator.nextObject() as? FIRDataSnapshot {
rest.ref.removeValue()
removeCount -= 1
if(removeCount == 0) {
@seyhunak
seyhunak / bubble_sort.swift
Created October 30, 2016 20:39
Bubble Sort Algoritm in Swift
import Foundation
func bubbleSort(inout numbers: [Int]) -> () {
let numbersLength = numbers.count
for i in 0 ..< numbersLength {
for j in 1 ..< numbersLength-i {
if numbers[j-1] > numbers[j] {
let swap = numbers[j-1]
numbers[j-1] = numbers[j]
@seyhunak
seyhunak / AppDelegate.swift
Created June 5, 2016 16:45
Yet another GitHub sign in screen using MVVM
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
window = UIWindow(frame: UIScreen.mainScreen().bounds)
let viewModel = LoginViewModel(provider: GitHubProvider)
let loginViewController = R.storyboard.main.loginViewController!
loginViewController.viewModel = viewModel
if let window = window {
window.rootViewController = loginViewController
window.makeKeyAndVisible()
@seyhunak
seyhunak / moya.swift
Created May 5, 2016 13:57
Moya - Sample
GitHubProvider.request(.UserRepositories(username), completion: { result in
var success = true
var message = "Unable to fetch from GitHub"
switch result {
case let .Success(response):
do {
let json: NSArray? = try response.mapJSON() as? NSArray
if let json = json {
@seyhunak
seyhunak / introrx.md
Created October 11, 2015 10:44 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@seyhunak
seyhunak / brewMVVM.swift
Created October 11, 2015 10:42 — forked from vasarhelyia/brewMVVM.swift
Brew MVVM
class Brew {
var temp: Float = 0.0
}
class BrewViewModel : NSObject {
var brew = Brew()
dynamic var temp: Float = 0.0 {
didSet {
self.brew.temp = temp
}