Skip to content

Instantly share code, notes, and snippets.

View shakemno's full-sized avatar

Manolis Pahlke shakemno

View GitHub Profile
codecov:
token: uuid # Your private repository token
url: "http" # for Codecov Enterprise customers
slug: "owner/repo" # for Codecov Enterprise customers
branch: master # override the default branch
bot: username # set user whom will be the consumer of oauth requests
ci: # Custom CI domains if Codecov does not identify them automatically
- ci.domain.com
- !provider # ignore these providers when checking if CI passed
# ex. You may test on Travis, Circle, and AppVeyor, but only need
@shakemno
shakemno / WatchSessionManager.swift
Created January 29, 2021 21:42 — forked from filsv/WatchSessionManager.swift
WatchConnectivity Singleton (Swift 5+, iOS+WatchOS Targets) + How to (comment below)
import WatchConnectivity
class WatchSessionManager: NSObject, WCSessionDelegate {
static let sharedManager = WatchSessionManager()
private override init() {
super.init()
}
private let session: WCSession? = WCSession.isSupported() ? WCSession.default : nil
@shakemno
shakemno / readme.md
Created January 6, 2021 10:35 — forked from xem/readme.md
Maths & trigonometry cheat sheet for 2D & 3D games

Conventions

  • A = [xA, yA] is a point on the 2D plane. Same for B, C, ...
  • lengths are in any unit (ex: pixels)
  • code snippets are in JavaScript

Degrees to radians

angleRad = angleDeg * Math.PI / 180;

@shakemno
shakemno / NotificationCenter+ObserveOnce.swift
Created December 27, 2020 17:24 — forked from fxm90/NotificationCenter+ObserveOnce.swift
Extension for "NotificationCenter" to observe a notification just once and directly unsubscribe.
//
// NotificationCenter+ObserveOnce.swift
//
// Created by Felix Mau on 18.10.20.
// Copyright © 2020 Felix Mau. All rights reserved.
//
import UIKit
extension NotificationCenter {
@shakemno
shakemno / Redux.swift
Created November 23, 2020 12:53 — forked from fxm90/Redux.swift
Playground showing how to use Redux with SwiftUI.
//
// Redux.playground
//
// Created by Felix Mau on 25.06.20.
// Copyright © 2020 Felix Mau. All rights reserved.
//
import PlaygroundSupport
import Combine
import SwiftUI
@shakemno
shakemno / generateRandomPastelColor.swift
Created November 22, 2020 00:24 — forked from JohnCoates/generateRandomPastelColor.swift
Randomly generate pastel UIColor in Swift
// Adapted from Stack Overflow answer by David Crow http://stackoverflow.com/a/43235
// Question: Algorithm to randomly generate an aesthetically-pleasing color palette by Brian Gianforcaro
// Method randomly generates a pastel color, and optionally mixes it with another color
func generateRandomPastelColor(withMixedColor mixColor: UIColor?) -> UIColor {
// Randomly generate number in closure
let randomColorGenerator = { ()-> CGFloat in
CGFloat(arc4random() % 256 ) / 256
}
var red: CGFloat = randomColorGenerator()
@shakemno
shakemno / reactiveswift+grdb.swift
Created September 23, 2020 08:35 — forked from RuiAAPeres/reactiveswift+grdb.swift
ReactiveSwift extensions for GRDB
/// This heavily based on the work done at RxGRDB
import GRDB
import ReactiveSwift
extension DatabasePool: ReactiveExtensionsProvider {}
extension DatabaseQueue: ReactiveExtensionsProvider {}
extension ValueObservation: ReactiveExtensionsProvider {}
extension DatabaseRegionObservation: ReactiveExtensionsProvider {}
extension Collection {
/// Returns an array of subsequences of maximum size `chunkSize`.
///
/// For example:
///
/// // ["ABCD", "EFGH", "IJ"]
/// "ABCDEFGHIJ".split(chunkSize: 4)
///
/// - parameter chunkSize: the maximum size of the returned subsequences.
/// - precondition: chunkSize > 0
@shakemno
shakemno / AsyncBroken.swift
Created July 27, 2020 21:35 — forked from brennanMKE/AsyncBroken.swift
Breaking async code in Swift
import PlaygroundSupport
import Foundation
class Worker {
private let queue = DispatchQueue.global(qos: .background)
private let serialQueue = DispatchQueue(label: "com.acme.serial")
public private(set) var count = 0
func incrementCount() {
class ThreadSafeCollection<Element> {
// Concurrent synchronization queue
private let queue = DispatchQueue(label: "ThreadSafeCollection.queue", attributes: .concurrent)
private var _elements: [Element] = []
var elements: [Element] {
var result: [Element] = []