You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Instantly share code, notes, and snippets.
Brian T. Rice
briantrice
I'm interested in languages, systems, and interfaces as a humanitarian concern. I work with data visualization authoring for general audiences.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.
You're Missing the Point of Promises
Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most
basic definition, your code will move from continuation-passing style:
getTweetsFor("domenic",function(err,results){// the rest of your code goes here.
Creation of unions, with automatic value constructors and an automatic fold encoding.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Please, before you call the police and get my
github account put on lockdown, allow me
a moment to explain. What I really want to do is work on projects that
advance the human condition and improve people's lives. I've been in a
mad dash to learn how to program for the past four or five years
exactly because I realized how much good I could do for the world with
a computer.
Turning PostgreSQL into a queue serving 10,000 jobs per second
Turning PostgreSQL into a queue serving 10,000 jobs per second
RDBMS-based job queues have been criticized recently for being unable to handle heavy loads. And they deserve it, to some extent, because the queries used to safely lock a job have been pretty hairy. SELECT FOR UPDATE followed by an UPDATE works fine at first, but then you add more workers, and each is trying to SELECT FOR UPDATE the same row (and maybe throwing NOWAIT in there, then catching the errors and retrying), and things slow down.
On top of that, they have to actually update the row to mark it as locked, so the rest of your workers are sitting there waiting while one of them propagates its lock to disk (and the disks of however many servers you're replicating to). QueueClassic got some mileage out of the novel idea of randomly picking a row near the front of the queue to lock, but I can't still seem to get more than an an extra few hundred jobs per second out of it under heavy load.
Recently I've been trying to modify the way that I use the word "just"
when I'm at work. Merriam Webster offers a few
definitions of the
word; the one I'm interested in is the one that means "only",
"simply", and to a lesser extent "exactly". I've been working on a new
project that involves integrating a number of systems, and as I began
rolling pieces out I received a lot a questions in the form of
"Couldn't you just ...?" These annoyed me at first, but as I thought
about it I realized I often asked questions in the same way, so I
began to examine the word and the way I use it.
A Guide to Functional Programming Lingo for JavaScripters
A Guide to Functional Programming Lingo for JavaScripters
Functional programming gets a bad wrap about being too hard for mere mortals to comprehend. This is nonsense. The concepts are actually quite simple to grasp.
The jargon is the hardest part. A lot of that vocabulary comes from a specialized field of mathematical study called category theory (with a liberal sprinkling of type theory and abstract algebra). This sounds a lot scarier than it is. You can do this!
All examples using ES6 syntax. wrap (foo) => bar means:
I imagine each of these chapters being about 2,000 words, making the whole book about the size of a small novel.
For comparison, articles in large papers like the New York Times average about 1,200 words.
Each topic gets whatever level of detail I can fit into that space.
For simple topics, that's a lot of space: I can probably walk through a very basic, but working, implementation of the IP protocol.