Skip to content

Instantly share code, notes, and snippets.

View pgherveou's full-sized avatar

PG Herveou pgherveou

View GitHub Profile
@pgherveou
pgherveou / dabblet.css
Created February 24, 2018 22:56
Untitled
// Hello
// test
background: #f06;background: linear-gradient(45deg, #f06, yellow);min-height: 100%;
@pgherveou
pgherveou / dabblet.css
Created February 23, 2018 00:51 — forked from anonymous/dabblet.css
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f07;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
@pgherveou
pgherveou / iPhone Model Mapping.txt
Last active July 22, 2020 00:45
iPhone Model Mapping.txt
Source https://stackoverflow.com/questions/11197509/how-to-get-device-make-and-model-on-ios
@"iPhone1,1" on iPhone
@"iPhone1,2" on iPhone 3G
@"iPhone2,1" on iPhone 3GS
@"iPhone3,1" on iPhone 4 (GSM)
@"iPhone3,3" on iPhone 4 (CDMA/Verizon/Sprint)
@"iPhone4,1" on iPhone 4S
@"iPhone5,1" on iPhone 5 (model A1428, AT&T/Canada)
@"iPhone5,2" on iPhone 5 (model A1429, everything else)
@pgherveou
pgherveou / async-operation.swift
Last active August 4, 2017 15:25
Async operationQueue
import Foundation
/// List of states that can be used to update an asynchronous operation state.
public enum AsyncOperationState {
case ready
case executing
case finished
fileprivate var keyPath: String {
switch self {
@pgherveou
pgherveou / yield-to-async.js
Created October 5, 2016 16:12
convert co/yield to to async/await
// http://astexplorer.net/#/BICnPGGYdU/4
export default function ({types: t}) {
return {
visitor: {
FunctionDeclaration(path) {
if (path.node.generator) {
path.node.async = true
path.node.generator = false
}
@pgherveou
pgherveou / reuse-shared-observable.swift
Last active October 6, 2016 17:10
reuse shared Observable
import Foundation
import PlaygroundSupport
import RxSwift
PlaygroundPage.current.needsIndefiniteExecution = true
/// dictionary of (id: shared Observable)
var store: [String: Any] = [:]
/// makeSequence return an existing shared sequence identified by `id`
@pgherveou
pgherveou / firstDifferenceBetweenStrings.swift
Created September 29, 2016 21:36 — forked from kristopherjohnson/firstDifferenceBetweenStrings.swift
Swift code to find differences between strings and display them in a readable way, useful for displaying unit test results
//: Playground - noun: a place where people can play
import Foundation
/// Find first differing character between two strings
///
/// :param: s1 First String
/// :param: s2 Second String
///
/// :returns: .DifferenceAtIndex(i) or .NoDifference
import PlaygroundSupport
import RxSwift
PlaygroundPage.current.needsIndefiniteExecution = true
extension ObservableType where E: Sequence {
typealias T = E.Iterator.Element
/// Create an observable which is an Array of the projected values
@pgherveou
pgherveou / concatMap.swift
Last active December 20, 2017 16:36
RxSwift + concatMap
import PlaygroundSupport
import RxSwift
PlaygroundPage.current.needsIndefiniteExecution = true
/// ConcatMap Operator
/// Runs all observable sequences in parallel and concat their elements.
extension ObservableType {
func concatMap<T>(project: @escaping (E) -> Observable<T>) -> Observable<T> {
return self.map { (element) -> Observable<T> in
import Foundation
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
/// define an operation success or error result
enum Result<T> {
case error(Error)
case success(T)
}