Skip to content

Instantly share code, notes, and snippets.

🏆
Winning The Life

Seyhun Akyürek seyhunak

🏆
Winning The Life
View GitHub Profile
View AppDelegate.swift
import Lokalise
func applicationDidBecomeActive(_ application: UIApplication) {
Lokalise.shared.checkForUpdates { _, _ in }
}
@seyhunak
seyhunak / AnalyticsManager.swift
Last active Jun 14, 2020
AnalyticsManager - Multiple Analytics Provider - Google, Firebase, Mixpanel, Facebook
View AnalyticsManager.swift
import UIKit
import Firebase
import FirebaseAnalytics
//MARK - Analytics Service
protocol AnalyticsService {
func initialize(application: UIApplication, launchOptions: [UIApplication.LaunchOptionsKey: Any]?)
func track(event: AnalyticsEvent, parameters: [AnalyticsEventParameter : String])
var trackingEvents: [AnalyticsEvent] { get }
@seyhunak
seyhunak / DispatchQueue+Extensions.swift
Created Jun 2, 2020
DispatchQueue extension for situations where one needs to run an expensive operation in background and then use its result in the main thread
View DispatchQueue+Extensions.swift
import Foundation
extension DispatchQueue {
func asyncConsumeInMainQueue<T>(
work: @escaping () throws -> T,
mainSuccess: @escaping (T) -> Void,
mainError: @escaping (Error) -> Void) {
async {
do {
let result = try work()
View AnalyticsManager.swift
import UIKit
public protocol AnalyticsServiceType {
var trackedEvents: [AnalyticsSectionEvent] { get }
func initialize(application: UIApplication, launchOptions: [UIApplication.LaunchOptionsKey: Any]?)
func track(event: AnalyticsEvent)
}
extension AnalyticsServiceType {
func shouldTrack(event: AnalyticsSectionEvent) -> Bool {
@seyhunak
seyhunak / DispatchGroup+Complete.swift
Created Dec 5, 2019 — forked from plummer/DispatchGroup+Complete.swift
DispatchGroup convenience wrapper for executing a series of blocks concurrently
View DispatchGroup+Complete.swift
import Foundation
extension DispatchGroup {
/// Completes a series of blocks and finally executes a completion handler.
///
/// - Parameters:
/// - label: An optional DispatchQueue label (defaults to bg)
/// - qos: An optional DipatchQos (defaults to background)
/// - blocks: The series of blocks to call.
View DynamicValue.swift
import Foundation
typealias CompletionHandler = (() -> Void)
class DynamicValue<T> {
var value : T {
didSet {
self.notify()
}
}
@seyhunak
seyhunak / git-clearHistory
Created Aug 30, 2019 — forked from stephenhardy/git-clearHistory
Steps to clear out the history of a git/github repository
View git-clearHistory
-- 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 Dec 12, 2017 — forked from willurd/web-servers.md
Big list of http static server one-liners
View web-servers.md

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
View Refreshable.swift
@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);
View Conversation.swift
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) {
You can’t perform that action at this time.