Skip to content

Instantly share code, notes, and snippets.

View benjamn's full-sized avatar

Ben Newman benjamn

View GitHub Profile
/** @jsx React.DOM */
define([
'react',
], function(React) {
var ReactCSSTransitionGroup = React.addons.CSSTransitionGroup;
var TestableCSSTransitionGroup = React.createClass({
@benjamn
benjamn / your_productivity.md
Last active August 29, 2015 14:04
BrooklynJS #9 Ruminations

We've all been told that "premature optimization is the root of all evil," but isn't that almost a tautology? As soon as we label something "premature" we've already basically decided it is undesirable. Try to think of some other premature things, and then classify them as "good" or "bad." One of those categories will be empty.

Premature optimization is a bad idea for the same reason anything else is a bad idea: it is at odds with—it works actively against—what actually matters. And I'm here to remind you that what actually matters in all but the most academic or maintenance-oriented kinds of programming is your productivity. In other words, there is no such thing as premature optimization for productivity. It is never too early to optimize for productivity, because productivity is one of those rare and slippery concepts, like Rationality, that is purely good by definition.

With that value structure in mind, I think we can say it better than Don Knuth:

Early optimization for productivity trumps all o

@benjamn
benjamn / gist:b2f5fcaffe9c83fcad3d
Last active August 29, 2015 14:19
Personal Flickr Importer Privacy Policy

PRIVACY POLICY

This app is not intended for general use. In other words, it has no privacy implications, and neither makes nor needs to make an privacy guarantees. Do not use this app.

@benjamn
benjamn / asyncRuntime.es6.js
Last active August 29, 2015 14:22
AwaitArgument example
let runtime = {
awrap(argument) {
return new AwaitArgument(argument);
},
"async"(generatorFunction) {
let generator = generatorFunction();
let previousPromise;
function callNext(...args) {
@benjamn
benjamn / gist:30895
Created December 1, 2008 23:30
undefined
template <typename M>
M* Create() {
ParserQueueMsg* msg = new M;
nsAutoLock synchronized(mLock);
Push(msg);
return static_cast<M*>(msg);
}
typedef struct Nil {};
template <typename H, typename T>
class Cons : public T {
protected:
typedef T BaseType;
H mVal;
public:
BaseType &operator()(H aVal) {
mVal = aVal;
typedef struct Nil {};
template <typename H, typename T>
class Cons : public T {
protected:
typedef T BaseType;
H mVal;
};
class Foo : public Cons<int, Cons<char*, Cons<bool, Nil> > >
template <typename CAR, typename CDR>
class cons : public std::pair<CAR, CDR>
{
public:
cons(CAR& car, CDR& cdr)
: std::pair<CAR, CDR>(car, cdr)
{}
};
diff --git a/js/src/xpconnect/src/xpcthrower.cpp b/js/src/xpconnect/src/xpcthrower.cpp
--- a/js/src/xpconnect/src/xpcthrower.cpp
+++ b/js/src/xpconnect/src/xpcthrower.cpp
@@ -257,16 +257,18 @@ XPCThrower::BuildAndThrowException(JSCon
// most likely out of memory
if(!success)
JS_ReportOutOfMemory(cx);
}
static PRBool
struct test_struct {
double f(int x, double y) {
return x + y;
}
};
double test() {
int x = 1;
double y = 1.5;
test_struct tc;