Skip to content

Instantly share code, notes, and snippets.

Eric Ferraiuolo ericf

Block or report user

Report or block ericf

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 ratelimit.py
import time
class Bucket(object):
def __init__(self, max_amount, refill_time, refill_amount):
self.max_amount = max_amount
self.refill_time = refill_time
self.refill_amount = refill_amount
self.reset()
def _refill_count(self):
View FluxStateIterator.js
const INCREMENT = 'INCREMENT', DECREMENT = 'DECREMENT';
function reducer(state, action) {
switch (action.type) {
case INCREMENT:
return state + 1;
case DECREMENT:
return state - 1;
}
}
@summerwind
summerwind / moz_first_paint.js
Last active Apr 27, 2016
FirstPaintTime for Firefox
View moz_first_paint.js
var firstPaint = 0, firstPaintTime, paint;
function paintHandler() {
paint = window.performance.now()
if (firstPaint === 0) {
firstPaint = paint;
firstPaintTime = firstPaint + window.performance.timing.navigationStart;
window.performance.timing.firstPaint = firstPaint;
window.performance.timing.firstPaintTime = firstPaintTime;
}
};
@gaearon
gaearon / combining.js
Created Jun 3, 2015
Combining Stateless Stores
View combining.js
// ------------
// counterStore.js
// ------------
import {
INCREMENT_COUNTER,
DECREMENT_COUNTER
} from '../constants/ActionTypes';
const initialState = { counter: 0 };
@jlongster
jlongster / forms-with-react.js
Last active May 8, 2017
higher-order form components w/react
View forms-with-react.js
// Simple wrapper to use bootstrap's grid system to position elements side-by-side
var VerticalFieldsElement = React.createClass({
render: function() {
return dom.div(
{ className: 'clearfix' },
React.Children.map(this.props.children, function(child) {
if(!child) {
return child;
}
@steveluscher
steveluscher / gist:4b54e08aa1e0536b7cb9
Last active Jan 14, 2019
Proposed abbreviation API for Intl.NumberFormat
View gist:4b54e08aa1e0536b7cb9

Intl.NumberFormat

Syntax

new Intl.NumberFormat([locales[, options]])
Intl.NumberFormat.call(this[, locales[, options]])

Parameters

View gist:598fa75e22bdfa44cf47

2015-01-29 Unofficial Relay FAQ

Compilation of questions and answers about Relay from React.js Conf.

Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).

View browserify_for_webpack_users.markdown

browserify for webpack users

There's been a strange explosion in misinformation about browserify recently, particularly in comparisons to webpack.

Generally speaking, most of this confusion stems from how webpack is more willing to pull features into its core to ease discoverability while browserify is more likely to push features out to userland instead.

I think that longer-term, separability has more benefits from a maintenance and

View router.js
"use strict";
var _ = SM.import('lodash');
var DOM = SM.import('sm-dom');
var Uri = SM.import('sm-uri');
// WebKit (as of version 538.35.8) fires a useless popstate event after every
// page load, even when the page wasn't popped off the HTML5 history stack. We
// only want to handle popstate events that result from a page actually being
// popped off the HTML5 history stack, so we need a way to differentiate between
@caridy
caridy / export-syntax.js
Last active Jun 25, 2019
ES6 Module Syntax Table
View export-syntax.js
// default exports
export default 42;
export default {};
export default [];
export default foo;
export default function () {}
export default class {}
export default function foo () {}
export default class foo {}
You can’t perform that action at this time.