Skip to content

Instantly share code, notes, and snippets.

Gwendal Roué groue

  • Pierlis
  • Paris, France
Block or report user

Report or block groue

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
View ReceiveValueOn.swift
import Combine
/// A publisher that delivers values to its downstream subscriber on a
/// specific scheduler.
///
/// Unlike Combine's Publishers.ReceiveOn, ReceiveValuesOn only re-schedule
/// values and completion. It does not re-schedule subscription.
struct ReceiveValuesOn<Upstream: Publisher, Context: Scheduler>: Publisher {
typealias Output = Upstream.Output
typealias Failure = Upstream.Failure
View ThrowingKeyPathProtocols.swift
//: # Toward Enum Key Paths: a Protocol Hierarchy for Read-Only Key Paths
//:
//: This playground is an experiment for a protocol hierarchy of read-only
//: key paths that can handle both throwing and non-throwing getters.
//:
//: Since the Swift language has no support for throwing subscripts, we'll
//: perform our experiments with a very simplified setup that involves a single
//: getter function.
//:
//: ## The Protocol Hierarchy
@groue
groue / ContextFetchableRecord.swift
Last active May 6, 2018
ContextFetchableRecord: a new realm of records for GRDB.swift
View ContextFetchableRecord.swift
// A replication of the convenience fetching methods of FetchableRecord,
// built for another record protocol: ContextFetchableRecord
protocol ContextFetchableRecord {
associatedtype Context
init(row: Row, context: Context)
}
extension ContextFetchableRecord {
View UIButton+Magic.h
@import UIKit;
@interface UIButton(Magic)
- (void)onTouchUpInside:(void(^)(UIButton *button))block NS_SWIFT_NAME(onTouchUpInside(_:));
@end
@groue
groue / JSONSynchronization.swift
Created Sep 13, 2017
GRDB JSONSynchronization
View JSONSynchronization.swift
// To run this playground, select and build the GRDBOSX scheme.
//
// This sample code shows how to use GRDB to synchronize a database table
// with a JSON payload. We use as few SQL queries as possible:
//
// - Only one SELECT query.
// - One query per insert, delete, and update.
// - Useless UPDATE statements are avoided.
import Foundation
View keybase.md

Keybase proof

I hereby claim:

  • I am groue on github.
  • I am groue (https://keybase.io/groue) on keybase.
  • I have a public key whose fingerprint is EDC5 4AA4 0D3A 475A DB0E 78B4 2A35 40DD A1C7 3F08

To claim this, I am signing this object:

@groue
groue / ReadWriteBox.swift
Created Nov 18, 2016
A ReadWriteBox grants multiple readers and single-writer guarantees on a value.
View ReadWriteBox.swift
/// A ReadWriteBox grants multiple readers and single-writer guarantees on a value.
final class ReadWriteBox<T> {
var value: T {
get { return read { $0 } }
set { write { $0 = newValue } }
}
init(_ value: T) {
self._value = value
self.queue = DispatchQueue(label: "ReadWriteBox", attributes: [.concurrent])
View PersonsViewController.swift
class PersonsViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Configure the navigation bar
navigationItem.rightBarButtonItems = [
UIBarButtonItem(
barButtonSystemItem: .Add,
target: self,
action: #selector(PersonsViewController.addPerson(_:))),
View PersonsViewController.swift
// MARK: - Navigation
extension PersonsViewController {
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "NewPerson" {
let navigationController = segue.destinationViewController as! UINavigationController
let controller = navigationController.viewControllers.first as! PersonEditionViewController
controller.title = "New Person"
controller.person = Person(name: "", score: 0)
View PersonEditionViewController.swift
extension PersonEditionViewController {
func applyChanges() {
person.name = nameTextField.text
person.score = scoreTextField.text.flatMap { Int($0) } ?? 0
}
}
You can’t perform that action at this time.