Skip to content

Instantly share code, notes, and snippets.

Florent Pillet fpillet

Block or report user

Report or block fpillet

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
@fpillet
fpillet / MeasurePerf.swift
Last active Jun 26, 2019
A tool to measure code performance in Swift
View MeasurePerf.swift
//
// Created by Florent Pillet on 14/11/16.
// Copyright (c) 2016 Florent Pillet. All rights reserved.
//
import Foundation
/*
* A utility struct that helps mesure the performance of sections of code. Only uses Foundation
* (we could also use QuartzCore's CACurrentMediaTime() for similar precision)
@fpillet
fpillet / Results+Rx.swift
Created Feb 13, 2016
turn Realm auto-updating Results into an RxSwift Observable sequence
View Results+Rx.swift
//
// Results+Rx.swift
//
// Make Realm auto-updating Results observable. Works with Realm 0.98 and later, RxSwift 2.1.0 and later.
//
// Created by Florent Pillet on 12/02/16.
// Copyright (c) 2016 Florent Pillet. All rights reserved.
//
import Foundation
@fpillet
fpillet / MainViewController.m
Created Oct 29, 2015
Example of encapsulating a gesture recognizer's behavior within a signal's callbacks
View MainViewController.m
- (void)setupDraggableHeaderGestureRecognizer {
// setup a gesture recognizer so we can drag the "I need some daytime hours" header up and down
@weakify(self);
UIPanGestureRecognizer *recognizer = [[UIPanGestureRecognizer alloc] init];
_draggableHeaderView.userInteractionEnabled = YES;
[_draggableHeaderView addGestureRecognizer:recognizer];
RACDisposable *disposable = [[[recognizer
rac_gestureSignal]
scanWithStart:RACTuplePack(@(_mapViewHeightConstraint.constant), @0)
@fpillet
fpillet / RACSignal+FPOperations.h
Last active Aug 29, 2015
Two RACSignal operations I use that are not in the main ReactiveCocoa distribution
View RACSignal+FPOperations.h
//
// Created by Florent Pillet on 30/01/15.
//
#import <Foundation/Foundation.h>
@interface RACSignal (FPOperations)
/// Delivers the receiver's latest `next`s with a minimum of `interval`
/// seconds between two values. Of `next` values produced by the receiver
View dispatch_once.m
dispatch_once_t once;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
dispatch_once(&once, ^{
NSLog(@"one");
dispatch_async(dispatch_get_main_queue(), ^{
once = 0;
dispatch_once(&once, ^{
NSLog(@"two");
@fpillet
fpillet / ViewModelServices.m
Created Oct 22, 2014
Chaining VCs from ViewModels
View ViewModelServices.m
- (void)pushViewModel:(BaseViewModel *)nextViewModel
{
NSString *from = [self standardNameFromViewModel:_currentViewController.viewModel];
NSString *to = [self standardNameFromViewModel:nextViewModel];
// We are going to try and find a segue to go to the next viewModel. The way segues are named
// in our storyboard should be: FromModel::ToModel
// 1. try Segue method. For example, a segue going from WelcomeViewController to LoginViewController would be named "Welcome::Login"
// 2. If a segue is not found, try to instantiate the view controller and push it directly. We look up the view controller by its stripped model name (i.e. "WelcomeViewModel" -> "Welcome")
// 3. If the view controller is not found in the storyboard, try a XIB with the stripped model name.
@fpillet
fpillet / PageFlipMonitor.js
Created May 7, 2013
Experimental Page Flip Monitor module for CommandFusion iViewer
View PageFlipMonitor.js
/* PageFlipMonitor v1.0
* Copyright 2013 CommandFusion, public domain
*
* Utility object that monitors entering and exiting pages,
* and can call any number of callbacks specifically registered to observe
* when entering or exiting a page
*
* You callback functions should be of the form:
*
function callback(fromPage, toPage) {
@fpillet
fpillet / gist:1779575
Created Feb 9, 2012
Detect whether the Android Soft Keyboard is up
View gist:1779575
containerView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener()
{
public void onGlobalLayout()
{
final Activity app = getActivity();
if (app == null)
return;
Rect r = new Rect();
containerView.getWindowVisibleDisplayFrame(r);
boolean visible = (Math.abs(r.height() - containerView.getHeight()) > 128);
@fpillet
fpillet / RequestQueue.js
Created Jan 24, 2012
Cancellable processing of iViewer CF.request calls
View RequestQueue.js
/* Use RequestQueue.request() instead of CF.request()
* At any point, to cancel all pending callbacks, call RequestQueue.clear()
*
*/
var RequestQueue = (function(){
var self = {
q: [],
next: 0
};
@fpillet
fpillet / OrderedRequestQueue.js
Created Jan 24, 2012
Ordered processing of CF.request() results for CommandFusion iViewer
View OrderedRequestQueue.js
/* OrderedRequestQueue.js
*
* Push CF.request calls using this object instead of directly using CF.request, and
* you'll be guaranteed to receive results in the order you pushed them. Note that this
* implies that the queue will BLOCK until each result is received in sequence, which may
* cause large delays if one site in the list is long to respond.
*
* Use at your own risk
*/
var OrderedRequestQueue = (function(){
You can’t perform that action at this time.