Skip to content

Instantly share code, notes, and snippets.

Nathan Barraillé nbarraille

Block or report user

Report or block nbarraille

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 keybase.md

Keybase proof

I hereby claim:

  • I am nbarraille on github.
  • I am nbarraille (https://keybase.io/nbarraille) on keybase.
  • I have a public key whose fingerprint is 636D C75E 5086 0743 C776 E53A BEF4 7BCB E1DC 16C2

To claim this, I am signing this object:

@nbarraille
nbarraille / gist:4252650
Created Dec 10, 2012
Threadz not finishing
View gist:4252650
require 'rubygems'
require 'threadz'
def dostuff(i)
sleep 1
raise "Exception" if i == 4
end
tp = Threadz::ThreadPool.new
batch = tp.new_batch
@nbarraille
nbarraille / mvp-example.java
Created Dec 3, 2015
Example of interface for MVP architecture
View mvp-example.java
interface MessageView {
// View methods should be directives, as the View is just executing orders from the
// Presenter.
// Methods for updating the view
void setMessageBody(String body);
void setAuthorName(String name);
void showTranslationButton(boolean shouldShow);
// Navigation methods
@nbarraille
nbarraille / BaseLoader.java
Created Dec 11, 2015
Base Loader for Android
View BaseLoader.java
public abstract class BaseLoader<T> {
AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() {
@Override
protected void onPreExecute() {
isNotReady = false;
isError = false;
isRunning = true;
}
@Override
View JacksonExample.java
// Deserializing list with invalid object
String json = "[{\"id\":\"123\"}, {}, {\"id\":\"125\"}]";
ObjectMapper mapper = new ObjectMapper();
List<MyObject> objects = mapper.readValue(json, new TypeReference<List<MyObject>>() {});
// This will throw IllegalArgumentException
// How can I make this return [MyObject{id=123}, [MyObject{id=125}] instead?
// Custom Object
@JsonDeserialize(builder = MyObject.Builder.class)
public class MyObject {
View Rinkeby address
0x32519afb756b0aebbdc714e2adb9fca1717f163d
View rate_limiter.py
class HeaderRateLimiter:
"""
A Rate Limiter context manager that reads headers commonly used by APIs
(such as Github, Twitter, ...).
Can be used in Multi-Threaded environments.
TODO: Add redis persistence to support multi-process/multi-machine
Usage:
rl = HeaderRateLimiter()
View PinchToZoomScaleDetector.java
/*
* The MIT License (MIT)
*
* Copyright (c) 2015 - Nathan Barraille
*
* 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
@nbarraille
nbarraille / OrientationChangeAction.java
Last active Aug 27, 2019
An Espresso ViewAction that changes the orientation of the screen
View OrientationChangeAction.java
/*
* The MIT License (MIT)
*
* Copyright (c) 2015 - Nathan Barraille
*
* 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
You can’t perform that action at this time.