Skip to content

Instantly share code, notes, and snippets.

View nbarraille's full-sized avatar
🦦

Nathan Barraillé nbarraille

🦦
View GitHub Profile
@nbarraille
nbarraille / contractMetadata.json
Last active April 28, 2022 15:49
Cohort Sample OpenSea Metadata
{
"name": "Amazeball's Collection!",
"description": "OpenSea Creatures are adorable aquatic beings primarily for demonstrating what can be done using the OpenSea platform. Adopt one today to try out all the OpenSea buying, selling, and bidding feature set.",
"image": "https://imagesvc.meredithcorp.io/v3/mm/image?url=https%3A%2F%2Fstatic.onecms.io%2Fwp-content%2Fuploads%2Fsites%2F47%2F2020%2F06%2F26%2Ftiny-white-kitten-873941684-2000.jpg",
"external_link": "https://www.efounders.com",
"banner_image_url": "https://preview.redd.it/o6cwlzg3exk41.png?auto=webp&s=eaad71f0c76522a309978bbd65b1a06902e56970",
"slug": "the-amazeball-collection-by-rick"
}
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()
0x32519afb756b0aebbdc714e2adb9fca1717f163d
// 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 {
@nbarraille
nbarraille / BaseLoader.java
Created December 11, 2015 21:04
Base Loader for Android
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
@nbarraille
nbarraille / mvp-example.java
Created December 3, 2015 00:45
Example of interface for MVP architecture
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

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:

/*
* 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 January 30, 2023 00:04
An Espresso ViewAction that changes the orientation of the screen
/*
* 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 / gist:4252650
Created December 10, 2012 19:13
Threadz not finishing
require 'rubygems'
require 'threadz'
def dostuff(i)
sleep 1
raise "Exception" if i == 4
end
tp = Threadz::ThreadPool.new
batch = tp.new_batch