Skip to content

Instantly share code, notes, and snippets.

Pete Hunt petehunt

  • Smyte
  • San Francisco, CA
Block or report user

Report or block petehunt

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 petehunt on github.
  • I am petehunt (https://keybase.io/petehunt) on keybase.
  • I have a public key whose fingerprint is 576E 36CB DFD3 E7B8 727F DFD0 EF59 1C35 8D68 A67F

To claim this, I am signing this object:

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

Redis in Production at Smyte

To be clear we continue to run many Redis services in our production environment. It’s a great tool for prototyping and small workloads. For our use case however, we believe the cost and complexity of our setup justifies urgently finding alternate solutions.

  • Each of our Redis servers are clearly numbered with a current leader in one availability zone, and a follower in another zone.
  • The servers run ~16 different individual Redis processes. This helps us utilize CPUs (as Redis is single-threaded) but it also means we only need an extra 1/16th memory in order to safely perform a BGSAVE (due to copy-on-write), though in practice it’s closer to 1/8 because it’s not always evenly balanced.
  • Our leaders do not every run BGSAVE unless we’re bringing up a new slave which is carefully done manually. Since issues with the slave should not affect the leader and new slave connections might trigger an unsafe BGSAVE on the leader, slave Redis processes are set to not automatically rest
View HoverRegion.jsx
'use strict';
var React = require('react');
var emptyFunction = require('../../jslib/emptyFunction');
var throttle = require('lodash.throttle');
var listening = false;
var instances = [];
View gist:bd5fa62610f80b6ec087
function makeStyle(defaults, tagName) {
tagName = tagName || 'div';
var Style = React.createClass({
getDefaultProps: function() {
return assign({}, defaults);
},
render: function() {
var style = assign({}, this.props);
delete style.children;
View gist:63096ce46439a686548e
var Style = React.createClass({
render: function() {
var style = assign({}, this.props);
delete style.children;
return React.createElement(
'div',
{style: style, children: this.props.children}
);
}
View gist:f590b37541e43c760c94
var bluebird = require('bluebird');
var request = require('request');
bluebird.promisifyAll(request);
bluebird.longStackTraces();
var helper = bluebird.coroutine(function*() {
yield request.getAsync('http://google.com/');
throw new Error('something unexpected happened');
});
View gist:4e8ec9fe13aacaf5a30b
var co = require('co');
var thunkify = require('thunkify');
var request = require('request');
var get = thunkify(request.get);
function *helper() {
yield get('http://google.com/');
throw new Error('something unexpected happened');
}
View gist:8595248

It looks like ReactDefaultPerf found some places you could add shouldComponentUpdate(). Great!

Keep in mind that just because there are lots of items in the table does not mean you need to add lots of shouldComponentUpdate() methods. Instead, simply try adding one to the highest-ranked component in the table and re-running the perf test. Often you'll see that it takes care of the other components on the list automatically for you.

For more information about shouldComponentUpdate() see http://facebook.github.io/react/docs/component-specs.html#updating-shouldcomponentupdate

You can’t perform that action at this time.