I'm Brett Slatkin and this is my personal site. I write code. These are my projects:

17 April 2014

Excited about PourOver from the NYTimes:

PourOver is a library for simple, fast filtering and sorting of large collections -- think 100,000s of items -- in the browser. It allows you to build data-exploration apps and archives that run at 60fps, that don't have to to wait for a database call to render query results.

14 April 2014

Canada still has working pay-phones and they're excellent.

13 April 2014

Fan-in and Fan-out: The crucial components of concurrency

Here's the video from my PyCon2014 talk!

11 April 2014

My talk from PyCon 2014

Code samples are here. Slides are embedded below (use slide forward/back buttons for best effect). Or download a PDF of the slides.



Video hopefully will be uploaded after the conference and I'll repost that too. Update: Here's the video!
Why do we need Tulip? I'll explain the motivation for Guido's asyncio module at my #pycon talk at 5:10pm today!

06 April 2014

Tip: If you aren't getting GitHub notifications properly, switch your primary email account to something else and then back to the original again. This kind of "solution" does not inspire confidence in a platform.

If you're looking for a starter project on Camlistore, build an importer that does this. Groundwork for indexable OCR.
Interesting paper that shows a connection between P ≠ NP and quantum behavior. I wonder if that analysis overcomes Gödel's incompleteness theorem, which says "a system cannot demonstrate its own consistency."
Two Python speed-up tools I learned of this week. Shame I can't use these in my production environment. They sound awesome.

Numba
Numba is an just-in-time specializing compiler which compiles annotated Python and NumPy code to LLVM (through decorators). Its goal is to seamlessly integrate with the Python scientific software stack and produce optimized native code, as well as integrate with native foreign languages.

Theano
Theano is a Python library that allows you to define, optimize, and evaluate mathematical expressions involving multi-dimensional arrays efficiently. Theano features: tight integration with NumPy, transparent use of a GPU...
Epic post about computer vision and machine learning.

03 April 2014

Why doesn't this guy just start a blog? I don't get it.
Woah: Pyston: an upcoming, JIT-based Python implementation. More details.

02 April 2014

Nice demo of how btrees speed up memory access in modern architectures.
"Performant" is still not a word.

31 March 2014

Good explanation of how to make JSON serialization faster in Go.

30 March 2014

Best thing I've read about the Mozilla debacle so far.
Nice little guide to running Go on an Android phone.

29 March 2014

Interesting update about Auroracoin, an attempt to give every Icelandic citizen cryptocurrency.

28 March 2014

Danah Boyd on how hormones affect vision and thus perception of VR (the real title of this article is awful).

27 March 2014

Saw Kraftwerk at the Fox Oakland. Lifelong dream! I got to keep the 3D glasses.

How to reheat pizza

Recently I was at one of my favorite pizza places on Earth, an old family style establishment in Lower Manhattan.

There were a few slices left over, and upon returning with them wrapped in foil our gracious host dropped this knowledge on me:

When the pizza arrives, it's hot: On the top you have molten cheese; below that is thin sauce; then you have soft warm bread followed by that nice crunch of the crust. But as it sits there and time goes by, the cheese firms up, the sauce thickens down into the bread making it soggy, and the crust softens.

When you get home you need to reverse the process.

Get a nice skillet and heat it up. Put the pizza down. You can use butter or oil, whatever. Now think about it: As it heats up from below the crust will get crunchy again; the bread will heat up and soften; the sauce will rise out of the bread and thin; the cheese will heat up and melt. You'll be back where you started.

I followed this man's directions and there's no doubt he's right. This was the best reheated pizza I've ever had. How have I gone a lifetime without knowing this method?

(PS: Yes, I'm paraphrasing his words. I wish I could have recorded the original)
I just flew in from Null Island and boy are my pointers expired.



Actual picture from the display on my flight after landing. (Sorry for the fuzzy photo)
Oldie but a goodie: Overview of cardinality estimators and their tradeoffs.
Notch weighs in on Oculus. This is the kind of post that platform creators dread.

He also linked to this amazing description of the existential crisis you feel when you leave good VR. This is futurism.

21 March 2014

The best analogy I can come up with.

19 March 2014

I can spot the bytes of a pickled Python object from 10000ms away.

14 March 2014

This post about building pipelines in Go is awesome. I would love to see this for all languages.

13 March 2014

With Sony open sourcing their Authoring Tools Framework and Valve their OpenGL debugger, maybe there's a coming renaissance in game development and shared tooling? Or maybe the tools are crap anyways.

12 March 2014

Streamtools looks like an interesting visualization of data pipelines. But I don't think graphical programming for this makes sense. So much of data analysis of any kind is "cleaning" the data to be sure you're counting the right things. That's usually the ugliest type of code you can write.

And Rust won't be fun anymore.

11 March 2014

Roundup of features in the new Javascript (aka ECMAScript 6).

10 March 2014

Finally some half-way decent networking gear from Intel at 800 Gbps per cable.

In spite of my code's outward appearance, I shall try to write a nice test.

09 March 2014

Catching up on 6 months of GitHub notifications I missed. Why doesn't it email you about pull requests and issues anymore? I feel dumb.

08 March 2014

I stopped showing icons on my desktop with this:

defaults write com.apple.finder CreateDesktop -bool false
killall Finder

And it's been great.
Autodesk Fusion 360 is the buggiest, crashiest piece of software I have used since Adobe Premier.

04 March 2014

I'm not motivated by shame. Who is?
Positivity encourages me. Be realistic not pessimistic.
Given all this SSL craziness, where is "one time pad" as a service? Crypto: delivered to your door in trucks by the ton.
ESR on remembering your history about open source:

The Unix guys showed us the way out, by (a) inventing the first non-assembler language really suitable for systems programming, and (b) proving it by writing an operating system in it. But they did something even more fundamental — they created the modern idea of software systems that are cleanly layered and built from replaceable parts, and of re-targetable development tools.

02 March 2014

I've open-sourced Quilla, my site that provides short-links for sending email.

26 February 2014

Oil Orange Terpene X 5-fold Dilimonene for dissolvable filament. Seems reasonable.

25 February 2014

Never forget Simpson's paradox.

Two awesome posts about elliptic curves (used in cryptography) by Jeremy Kun.
Saw this behavior today:

>>> mimetypes.guess_extension('text/plain')
'.ksh'

O_o

Behold, mimetypes.py, a gem from the Python standard library:

def guess_extension(self, type, strict=True):
    """Guess the extension for a file based on its MIME type.

    Return value is a string giving a filename extension,
    including the leading dot ('.').  The extension is not
    guaranteed to have been associated with any particular data
    stream, but would be mapped to the MIME type `type' by
    guess_type().  If no extension can be guessed for `type', None
    is returned.

    Optional `strict' argument when false adds a bunch of commonly found,
    but non-standard types.
    """
    extensions = self.guess_all_extensions(type, strict)
    if not extensions:
        return None
    return extensions[0]

If there are multiple possibilities, return one at random. In this case, a Korn Shell script.

23 February 2014

Feeling like a kid again – The joy of 3D printing

When I was 13 I became obsessed with programming. I was finally good enough at writing code to hack away like a madman. When I found a new programming problem I would work on it all night. I would enter the flow state. I wouldn't notice time passing. I'd dream about it and go right back in the morning. I was inventing problems at the same time I was solving them. Programming made me so happy (and still does today).

For the past 30 days I've had that same feeling, something I haven't experienced since I was 13 years old. I've been creating non-stop, obsessed with my latest experiments. I haven't been able to sleep, staying up until 4am focused on making one more smidgeon of progress. It's been a blast! But my time hasn't been spent programming. It hasn't been the occasional strategy game that has a similar effect (Civilization, Sim City, Starcraft, etc). What's made me feel like a kid again is my 3D printer and the promise of rapid prototyping.


The project

I'd been considering an idea for the past few months: Design a new gear shifter for my bicycle. I wasn't interested in a typical derailleur shifter, but a custom shifter for the Shimano Nexus 8 internally geared hub used by Mission Bicycle*:



This hub is a non-standard part. The geometry is totally different than what's out there. The chain never moves off the chain rings. All of the moving parts are hidden away. It looks awesome and works great (better than my old 12 speed bike). But the standard shifters for it look like this monstrosity:



There are two other compatible, aftermarket shifters out there, but I don't like their look either.

The question was: What would it take to create my own?


Prototyping the shape

On January 18th I set out to make my own shifter a reality. The CAD software I decided to use was 123D Design from Autodesk (it's free!). I did some Alias back in school, so I'm not a total newbie, but look how horrible my first attempt at modeling the shifter was:



After a few days of experimentation with the CAD package I had a better design. What surprised me about CAD modeling is I'd enter the flow state just like I do when programming. I'd have to think hard about how the geometry moves and fits together, just like I simulate how a program will behave in my head, poking data in and out of memory. It made me ridiculously happy.



The screws and springs you see in there are CAD models I downloaded off a supplier's website. I had no idea how sophisticated the supply chain is for this stuff.

Meanwhile, I bought a 3D printer, the MakerBot Replicator 2X. I chose MakerBot because it's well supported. Here's a video of that thing in operation. The sound it makes is futuristic and haunting:



The CAD program exports an STL file (a mesh of triangles). The MakerWare software that came with my printer turns this into an execution plan (akin to Logo) that you can check for errors. The flat bottom parts are called "rafts", easily removable supports that prevent the ABS plastic from curling off the build plate.



Here it is printed into reality:



A few days later I prototyped how the pieces (screws, springs, ball bearings) would fit together, and had an assembly that could move:



What followed was a huge amount of trial and error to make the geometry shift the gears in precisely the right way. I also had to figure out how to make the holes more durable against the crushing impact of the indexed shifting springs. Here's the pack of duds I printed on my way to making it work. Each of these took about 75 minutes to print at 15% fill (meaning they are 85% hollow and chintzy):



But finally, miraculously, I made the shifter work. Here it is shifting the hub for the first time:




Iterating the design

After this things escalated quickly. I brought the prototype to the bike shop. We put it on a bike and found a design flaw: In high gears the knob would bang against the top tube when you turn the handlebars. It's finding problems like this that makes 3D printing amazing. I had been prototyping for weeks and thinking about it all the time, but I still overlooked simple constraints that become obvious once you actually try it out. Fixing those problems was fast and cheap.



I went home that night, spent a few hours rotating the geometry 90° forwards, and then did a 100% fill print to make it strong. The next morning I dropped the new parts off at the bike shop. They built the bike out. By the afternoon, all the pieces were in place: We had a fully built bicycle with the new shifter. The day was February 18th, exactly 30 days after I started the CAD drawings.



I rode the bike home that day and have been riding it a bunch since. I've also improved the design further, shrinking the base and knob to make the whole thing more ergonomic. What's crazy is how fast you can iterate. This design I thought of at 10am, had it in CAD by 10:30, had a print by 12:30, had it on the bike by 1pm. Being able to move this quickly reminds me of the liberating feeling of continuous deployment for building software. Having a 3D printer makes me feel like I can create anything. I'm no longer afraid of the physical constraints of designing real objects.




What's next

Now I'm looking for a machine shop to turn this part into a reality. ABS plastic is fine for a demo, but for durability and precision having it CNC'ed out of aluminum would be best. I want to anodize it in cool colors. I have no idea how much this will cost or how much time it will take. I'll write up that experience in another installment of this story as soon as it's done.


* Disclosure: I'm part owner of Mission Bicycle.

19 February 2014

Added documentation to my Cohort Visualizer tool to explain what the calculations mean, reproduced here. This shit is more complicated than I remember:



A "bar" is every cohort for a particular day. A "bar segment" is one part of the bar for a day in single color, corresponding to a particular "cohort state" (like "Made two posts" above), which is usually some level of progression in the funnel.


∑↑ / ∑↕ "Percentage here and up"

Sum the bar your mouse is over vertically upward, including the bar segment your mouse is on top of. Then divide by the total sum for that bar vertically. Answers: "On this day, what percentage of users are beyond and including this cohort state in the funnel?" For the bottom bar segment this will be 100%.

∑↓ / ∑↕ "Percentage here and down"

Sum the bar your mouse is over vertically downward, including the bar segment your mouse is on top of. Then divide by the total sum for that bar vertically. Answers: "On this day, what percentage of users are before and including this cohort state in the funnel?" For the top bar segment this will be 100%.

X / ∑← "Percentage here of cumulative past sum"

Sum all bar segments from the cohort state you have your mouse over going back in time to the left, including the one your mouse is over. Divide the bar segment you have your mouse over by that sum. Answers: "What percentage of users does the highlighted bar segment represent as part of the whole past for that cohort state, including this day?"

X / ∑→ "Percentage here of cumulative future sum"

Sum all bar segments from the cohort state you have your mouse over going forward in time to the right, including the one your mouse is over. Divide the bar segment you have your mouse over by that sum. Answers: "What percentage of users does the highlighted bar segment represent as part of the whole future for that cohort state, including this day?"

X / ∑↔ "Percentage here of cumulative sum over time"

Sum all bar segments for the cohort state you have your mouse over for all days. Divide the bar segment you have your mouse over by that sum. Answers: "What percentage of users does the highlighted bar segment represent over all time for that cohort state?"

∑← / ∑↔ "Contribution of past to cumulative sum over time"

Sum all bar segments from the cohort state you have your mouse over going back in time to the left, including the one your mouse is over. Answers: "What percentage of users over all time got into the highlighted cohort state before and including the highlighted day?" For the last day this will be 100%.

∑→ / ∑↔ "Contribution of future to cumulative sum over time"

Sum all bar segments from the cohort state you have your mouse over going forward in time to the right, including the one your mouse is over. Answers: "What percentage of users over all time got into the highlighted cohort state after and including the highlighted day?" For the first day this will be 100%.

X / Max ↔ "Percentage of maximum single day ever"

Find the biggest bar segment for the cohort state you have your mouse over for all time. Divide the bar segment you have your mouse over by the the biggest amount. Answers: "How big is this day for users to get into the highlighted cohort state compared to all other days ever?" The biggest day will be 100%.

1 - X / Max ↔ "Delta from maximum single day ever"

Find the biggest bar segment for the cohort state you have your mouse over for all time. Divide the bar segment you have your mouse over by the the biggest amount. Subtract that from 100%. Answers: "How much bigger is the biggest day ever for this cohort state compared to this day?" The biggest day will be 0%.
Rode my bike today with a new shifter that I designed and 3D printed myself.



I'm excited to tell you more about it!
3D printing is to design what continuous deployment is to code.

17 February 2014

Is there a Bitcoin Script demoscene yet? BTC1K?
© 2009-2014 Brett Slatkin