RSS Amplifier

Blog

Leon Trolski

The website of Leon Trolski

leontrolski.github.ioRSS feed ↗11 posts

Latest posts

The CMD-click manifesto

The CMD-click manifesto Or CTRL-click or META-click or whatever. Being able to CMD-click through code >> any other theoretical concerns. CMD-clickability is the opposite of indirection - how does this function work? CMD-click it. Non-CMD-clickable codebases are filled with non-meaningful abstractions and tend to be longer. Static analysis tooling should be easy to write. Stack traces should…

A developer's summary of Consciousness and the Social Brain</em>

A developer's summary of Consciousness and the Social Brain " Consciousness and the Social Brain " is a book by Princeton neuroscience professor Michael Graziano , outlining his theory of consciousness - the attention schema theory . This is a developer's summary only in that I can't imagine many other people having much interest in this website. Having said that, the theory itself is one of…

33 line React

&#x26a0;&#xfe0f; This article contains JS code. It might not work properly in your feed reader. You might want to visit the original article . 33 line React Thoughts on reading through the hacker news response . 96 line version with JSX compiler. React you pass in a function that takes state and returns a virtual DOM (just a tree of plain ol' js objects) it renders that virtual DOM as a real DOM…

96 line React with JSX

&#x26a0;&#xfe0f; This article contains JS code. It might not work properly in your feed reader. You might want to visit the original article . 96 line React with JSX A while ago, I wrote a short post showing a minimal 33 line React . A lot of the comments focused on the Mithril -like syntax for the virtual DOM. So that we can ignore that aspect, here is a 96 line React with a JSX compiler .…

What nested SQL queries might look like

What nested SQL queries might look like A friend was talking to me about ORM design recently. I'm a heavy SQLAlchemy user, but see all the reasons people dislike ORMs, so on a recent project I had a go at dipping back down to raw SQL land to see how I'd cope. I ended up finding the experience pretty frustrating - I'm sure someone will have written it before, but there's definitely some Greenspun's…

Make python-style classes from not much javascript

Make python-style classes from not much javascript It's been said many times before, objects are a poor man's closures are a poor man's objects , this is a deep and important thing . In python and javascript, the leap is really quite small. I thought I'd try drum the lesson home by implementing a limited bit of the python object system with a subset of javascript. We will: Describe a small subset…

33 line React - thoughts

33 line React - thoughts Original post , original discussion . There were lots of insightful comments in the hacker news thread - thanks, I thought I'd write up some of the thoughts that came out of it. Looking now, this may just be a rant piece - I'll let you decide. In a vaguely Top-Gear-esque way, this post is split into style , performance , conclusions . TLDR Have a go building your next…

Postgres advisory locks for <code>python</code> developers.

Postgres advisory locks for python developers. Postgres docs for locking in general , advisory locks in specific . Everyone should use postgres' advisory locks, they're great! Why? What are they? Who cares? With an advisory lock, you can get a lock on an arbitrary integer for the duration of a transaction. This is very useful as you can: Get a lock on, for example, a hash of the tuple…

Recursing with <code>yield</code>

Recursing with yield This post shows a simple python / js pattern for recursing through code that probably should get a bit more usage. Say you have the following data: tree = { "a": 4, "children": [ { "a": 3, "children": [] }, { "a": 2, "children": [ { "a": 6, "children": [] } ] }, ] } And you want to get all the a values greater than 2. In python , the "classic" way would be to do: def…

What if we'd had better <code>html</code>-in-<code>js</code> syntax all along?

What if we'd had better html -in- js syntax all along? I have a theory that a grave mistake was made in 1995 - the decision not to have a neat, succinct and declarative way of representing html elements in javascript. [On reading the hacker news comments this is pretty historically inaccurate, however, I think this article still stands as "look just how close javascript object notation is to a…

How do pandas DataFrames work? (kinda)

How do pandas DataFrames work? (kinda) When you're used to plain ol' dict s, int s, list s etc, pandas.DataFrame s exhibit some weirdo behaviour, particulary concerning assignment and operators. This page is a short walk-through of how some of these things happen (and a quick intro to Python's magic methods), you can see the outcome here . Disclaimer: the things presented here are not entirely as…