Skip to content

Instantly share code, notes, and snippets.

View juliengdt's full-sized avatar
🎯
Focusing

juliengdt juliengdt

🎯
Focusing
View GitHub Profile
@juliengdt
juliengdt / Playground.swift
Created January 22, 2018 17:08
Backend dude, what have you done ?
/* 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)] = self.map{ dict -> [String: String] in
@juliengdt
juliengdt / ProtocolInEnum.swift
Created January 16, 2018 09:13
Protocol For Enumeration - Swift 4
//: Playground - noun: a place where people can play
import UIKit
import Foundation
var str = "Hello, playground"
protocol JSONRepresentable {
var JSONRepresentation: AnyObject{ get }
}
@juliengdt
juliengdt / SomePlayground.swift
Last active September 21, 2019 15:55
Strongly Type Identifiers For Class Or Struct By Using Protocol and associated types
/*
In response of Tom Lokhort's article.
A third alternative: alternative 2 under steroïds
---
Source: http://tom.lokhorst.eu/2017/07/strongly-typed-identifiers-in-swift
*/
struct GenericIdentifier<T>: RawRepresentable, Hashable, Equatable {
let rawValue: String
@juliengdt
juliengdt / Soumission Apple Appstore - iOS.md
Last active July 28, 2020 17:10
Soumission Apple Appstore - iOS

Soumission Apple Appstore - iOS

Ce document liste toutes les informations nécessaires afin de soumettre rapidement une application iOS sur iTunesConnect pour:

  • Une nouvelle application
  • Une mise à jour d'application

Nouvelle Application

@juliengdt
juliengdt / StringExt-Markers.swift
Last active March 20, 2017 13:59
String extension/helper to use to remove a HTML/custom marker - Swift 3.X
extension String {
func deleteOccurences(of: String) -> String {
return self.replacingOccurrences(of: of, with: "")
}
func deleteMarker() -> String {
let markerBRange = self.range(of: "<")
extension UICollectionView {
public var rx_reachedBottom: Observable<Void> {
return self.rx.contentOffset
.map { contentOffset in
var responder: UIResponder = self
var viewController: UIViewController? = nil
while let next = responder.next {
viewController = next as? UIViewController
if viewController != nil {
@juliengdt
juliengdt / DynamicTypeMadeItEasy.swift
Created September 26, 2016 16:04
Dynamic Type handling in Swift 3, just by using Dynamic Type as Font everywhere in the app, no more manual refresh on notification needed
//
// FontConfiguration.swift
// juliengdt
//
// Created by Julien Goudet on 26/09/2016.
// Based on: https://www.iphonelife.com/blog/31369/swift-programming-101-mastering-dynamic-type-ios
//
import Foundation
@juliengdt
juliengdt / AlamofirePrintable.swift
Created September 1, 2016 09:24
Pretty print extension for Alamofire Request
extension Alamofire.Request {
func responseDebugPrint() -> Self {
return responseJSON() {
response in
if let JSON: AnyObject = response.result.value,
JSONData = try? NSJSONSerialization.dataWithJSONObject(JSON, options: .PrettyPrinted),
prettyString = NSString(data: JSONData, encoding: NSUTF8StringEncoding) {
print(prettyString)
} else if let error = response.result.error {
print("Error Debug Print: \(error.localizedDescription)")
@juliengdt
juliengdt / HCElasticFlowLayout.m
Created July 18, 2016 13:17
HCElasticFlowLayout - Elastic Flow layout for UICollectionView
#import <UIKit/UIKit.h>
#ifndef __IPHONE_7_0
#error Because of Dynamic Kit, this custom flowLayout requires APIs only available in iOS SDK 7.0 and later
#endif
/**
* A UICollectionViewFlowLayout subclass that, when implemented,
* creates a dynamic / elastic scroll effect for UICollectionViews
*/
@juliengdt
juliengdt / UILabel+Formattable.m
Created July 12, 2016 12:23
Bold UILabel text by loading it to attributedText, quitted by "*--*"
- (void)boldSubText
{
NSString *textToAttribute = @"abcdefg*-hijklm-*nopqrst*-uvwxyz-*";
NSDictionary *boldAttributeDict = @{NSFontAttributeName:
[UIFont robotoBoldFontOfSize:MODAL_INFORMATION_FONT_SIZE_DESCRIPTION]};
NSArray<NSString *> *splittedSubText = [textToAttribute componentsSeparatedByString:@"*"];
NSMutableArray<NSAttributedString*> *splittedAttributedStringArray = [[NSMutableArray alloc] initWithCapacity:splittedSubText.count];
[splittedSubText enumerateObjectsUsingBlock:^(NSString *_Nonnull splittedString, NSUInteger idx, BOOL *_Nonnull stop) {