Skip to content

Instantly share code, notes, and snippets.


juliengdt juliengdt

Block or report user

Report or block juliengdt

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 tuple and map
let otherTableau: Array<(Int, String)> = [(1,"a"),(2,"b"),(3,"c"),(4,"d")]
let mean = { tuple -> Int in
return tuple.0
On peut aussi écrire le map de mean de cette facon, pour raccourcir l'écriture
"$0" est "le premier argument"
juliengdt / Numeric+Normalization.swift
Created Jul 4, 2019
Put any numeral between two intervals, exactly like a numeric compass [0° <-> 360°] behavior.
View Numeric+Normalization.swift
extension Numeric where Self: Comparable /* NORMALIZER */ {
/// normalize the current value between a min and a max interval, by adding optionaly a value. this works just like the compass normalization. for Ex, 357°, by adding +4 became 1° for [0 - 360] interval
/// - Parameters:
/// - value: the value to add
/// - min: the minimum interval
/// - max: the maximum interval
/// - Returns: the new, transformed and normalized value
juliengdt / gist:aa0554bc32d1f34c1f247e1b140115f1
Created May 24, 2019
View gist:aa0554bc32d1f34c1f247e1b140115f1
extension CGImage {
var brightness: Double {
get {
let imageData = self.dataProvider?.data
let ptr = CFDataGetBytePtr(imageData)
var x = 0
var result: Double = 0
for _ in 0..<self.height {
for _ in 0..<self.width {
let r = ptr![0]
View Enums with RawRepresentable Example
enum Restaurant: RawRepresentable {
typealias RawValue = Array<Int>
case toto
case tata
var rawValue: Array<Int> {
switch self {
case .tata:
juliengdt / Routing+Repositioning.swift
Last active Mar 29, 2019
Swift side of the "repositioning-in-routing-request" (protocol is Android interface)
View Routing+Repositioning.swift
/// **From App to SDK(system)**
/// Give informations thanks to user interaction
/// Called by the app, when user interacts about routing or location stuff
/// `[App].call(sdkSystemDatasource.function(params))`
protocol PositionHelperDatasource {
/// Call this datasourced-function when a routing or a re-position is asked by the user
View GridLayout.swift
* Copyright (c) 2017 Razeware LLC
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
juliengdt / NSObject_Extensions.swift
Created Mar 21, 2018
Because NSObject KV setter sucks by default
View NSObject_Extensions.swift
extension NSObject {
private enum SetValuableErrorType: Error, CustomStringConvertible {
case unknown(key: String, type: NSObject)
var description: String {
switch self {
case .unknown(key: let k, type: let t):
return "Unknown parameters \(k) for object typped \(String(describing:t))"
View Reactive extension on Generic stuff
import Foundation
import Result
import RxSwift
enum ResponseErrorType: Error, CustomStringConvertible {
case technical
case notFound
case other(message: Array<String>)
juliengdt / Playground.swift
Created Jan 22, 2018
Backend dude, what have you done ?
View Playground.swift
/* 1 - When your backend dev doesn't know how to REST*/
let backEndLOL: [[String: String]] = [["Key":"CAPACITY","Value":"323"],["Key":"rate","Value":"3.00"]]
// Okay let's do his/her job
extension Collection where Iterator.Element == [String: String] {
var trueFuckingJson: [String: String] {
let tupleArray: [(String, String)] ={ dict -> [String: String] in
juliengdt / ProtocolInEnum.swift
Created Jan 16, 2018
Protocol For Enumeration - Swift 4
View ProtocolInEnum.swift
//: Playground - noun: a place where people can play
import UIKit
import Foundation
var str = "Hello, playground"
protocol JSONRepresentable {
var JSONRepresentation: AnyObject{ get }
You can’t perform that action at this time.