Skip to content

Instantly share code, notes, and snippets.

View juliengdt's full-sized avatar
🎯
Focusing

juliengdt juliengdt

🎯
Focusing
View GitHub Profile
@juliengdt
juliengdt / UIImageView+DottableExtension.m
Created July 5, 2016 09:03
Extension for UIImage to set a dotted pattern as image source
@interface UIImageView (DottableImage)
- (void) dottedPatternFrom:(CGPoint)fromPoint to:(CGPoint)toPoint forWidth:(CGFloat)width;
@end
@implementation UIImageView (DottableImage)
float const DefaultDottedImageWidth = 5.0f;
@juliengdt
juliengdt / uncrustify.cfg
Last active July 5, 2016 13:12
Uncrustify Configuration file, sticked to Raw Wenderlich Objective-C style guide. This document is to copy on YOUR root folder (near Documents/)
#
# Uncrustify Configuration File
# File Created With UncrustifyX 0.4.3 (252)
#
# Alignment
# ---------
## Alignment
@juliengdt
juliengdt / pipinstall.py
Created June 16, 2016 08:55
PIP Installation
This file has been truncated, but you can view the full file.
#!/usr/bin/env python
#
# Hi There!
# You may be wondering what this giant blob of binary data here is, you might
# even be worried that we're up to something nefarious (good for you for being
# paranoid!). This is a base85 encoding of a zip file, this zip file contains
# an entire copy of pip.
#
# Pip is a thing that installs packages, pip itself is a package that someone
# might want to install, especially if they're looking to run this get-pip.py
require 'formula'
class Oclint < Formula
homepage 'http://oclint.org'
url 'https://github.com/oclint/oclint/releases/download/v0.10.2/oclint-0.10.2-x86_64-darwin-15.2.0.tar.gz'
version '0.10.2'
sha1 '4b61f83ccd55eeaa968ca5ee159e2528b4fbfeb5'
devel do
url 'https://github.com/oclint/oclint/releases/download/v0.10.2/oclint-0.10.2-x86_64-darwin-15.2.0.tar.gz'
@juliengdt
juliengdt / ErrorEnum.h
Created May 26, 2016 07:45
HTTP Error code enumerations - Objective-C
typedef NS_ENUM(NSInteger, HTTPCodeInformation) {
Continue100 = 100,
SwitchingProtocols101 = 101,
Processing102 = 102
};
typedef NS_ENUM(NSInteger, HTTPCodeSuccess) {
Success200 = 200,
Created201 = 201,
@juliengdt
juliengdt / lowpower_mode.md
Last active August 26, 2023 18:26
Detect and make your iPhone app responds to low-power mode

Low Power Mode - LPM

With iOS 9 Apple added a Low Power Mode to the iPhone. It extends battery life by stopping some battery heavy features such as email fetch, Hey Siri and background app refresh until you can recharge the device.

It is important to understand that it is the user who decides to enter low power mode. You need to go into the battery settings to turn it on.

Detection

To detect LPM you have to be in the couple iOS 9.X / iPhone:

  • For iOS 8.X, you need test availablity before use it
@juliengdt
juliengdt / HCLog_Playground_V2.swift
Last active May 19, 2016 09:28
Swift Protocol Logger with level condition, Swift 2.X and Swift 3.X version
//: Playground - noun: a place where people can play
// Usage for Swift 2.X using the deadly old Swift Debugger Identifiers, ie: __FILE__
// @see: https://github.com/apple/swift-evolution/blob/master/proposals/0028-modernizing-debug-identifiers.md
enum LogLevel: Int {
case verbose = 1
case debug = 2
case info = 3
case warning = 4
struct Throttle {
static func onQueue(queue: NSOperationQueue, by timeInterval: NSTimeInterval, function: () -> ()) {
queue.cancelAllOperations()
let delayOperation = DelayOperation(timeInterval: timeInterval)
let throttledOperation = NSBlockOperation() {
function()
}
throttledOperation.addDependency(delayOperation)
queue.addOperations([delayOperation, throttledOperation], waitUntilFinished: false)
@juliengdt
juliengdt / CollectionTypeSkipper.swift
Created March 30, 2016 14:15
CollectionType Skipper
// MARK: - CollectionType Addition
extension CollectionType {
/**
Create and return a new CollectionType made with only skipped items, which index is not a divider of "skip"
- parameter skip: the divider index
- returns: the new collectionType
*/
func skip(skip: Int) -> [Generator.Element] {
@juliengdt
juliengdt / Theme.swift
Created October 28, 2015 08:43
Theme in swift, just by applying in your appDelegate Theme.applyThemeAppearance()
//
// Theme.swift
// juliengdt
//
// Created by julien.GOUDET on 26/10/2015.
// Copyright © 2015 julien.GOUDET. All rights reserved.
//
import Foundation
import UIKit