traviscj/blog

Posts

May 18, 2020

interceptors

INTERCEPTORS ARE SO COOL! Sometimes you need some “generic rails” that are still highly adaptable to other uses. This is the basic problem solved by the Interceptor pattern. I really love the way OkHttp does interceptors for the generic rails of making HTTP calls, so I wanted to walk through a case study of why an interceptor might be useful and then try to synthesize some lessons & a minimal example of the pattern.
April 1, 2020

Hugo

I’ve decided to migrate the blog to Hugo, as you might have noticed from the new look. This is gonna be a pretty big project and I’m probably going to be at it a while. I did keep a copy of the old blog at blog.jekyll but it seems the formatting is already broken there :-(
June 11, 2019

feeds justification

I realized I’ve left out a major part from my sequence of previous feed-related posts: a justification for why we should bother with a separate feed_sync_id. So let’s give it a shot! The fundamental problem is: AUTO_INCREMENT ids are assigned in insertion order, but become visible to other threads in commit order. To see how this causes a problem, consider the interactions and visibilities between three transactions to the same database:
May 23, 2019

macos log command

My work laptop has been randomly shutting itself off. I came across this stackoverflow post, it said to run log show \ --predicate 'eventMessage contains "Previous shutdown cause"' \ --last 24h which, for me, returns risksys ➜ log show --predicate 'eventMessage contains "Previous shutdown cause"' --last 24h Filtering the log data using "composedMessage CONTAINS "Previous shutdown cause"" Skipping info and debug messages, pass --info and/or --debug to include. Timestamp Thread Type Activity PID TTL 2019-05-23 11:29:01.
April 25, 2019

absolutely minimal OLTP to OLAP pipeline

Suppose we have some data in a production OLTP database, and we need to send it to some OLAP database. This post describes one of the simplest approaches, and how to make it productional enough to rely on. For every table t, we need to: introduce a new field, updated_at introduce a new index on that field, so we can get the records that changed after a certain updated_at. For example,
February 21, 2019

smart arguments

It’s easy to love the terseness one can get out of a command-line tool with a “pass by order” convention. For example, maybe I run something like deploy myapp sea2 production to deploy an application called myapp to the second production datacenter near Seattle. This works great, except now I need to remember the order of arguments is: deploy [app] [datacenter] [environment]. The typical solve for this problem is introducing named arguments, so you’d end up with
January 8, 2019

feed sequences

In the mysql feeds post, I mentioned that the publisher could do SELECT MAX(feed_sync_id)+1 FROM kv to find the next feed_sync_id during the publishing process, but this is actually a really bad idea. (And I knew it at the time, so forgive me for selling lies…) Republishing Before we jump into the problematic scenario, I’d like to motivate it with a tiny bit of background. The republish operation is extremely useful when consumers need to receive updates.
January 7, 2019

pattern: extract mutating variables to State class

I’ve come to really like the pattern of extracting local or instance variables into their own State class, and writing an algorithm in terms of that State. A really trivial (if contrived) example of this would be a “sum cubes” algorithm; something like this: public class CubeSummer { private final PrintStream printStream; private long i; private long sum; public CubeSummer() { this.printStream = System.out; reset(); } public long sumCubes(long limit) { for (; i<limit; i++) { sum += i * i * i; display(); } return sum; } public void reset() { i = 0; sum = 0; } public void display() { printStream.
January 6, 2019

unreasonable wish -- an sql interface to websites

I was searching Amazon Prime for some Earl Grey tea for my wife. I got these results This was just a basic search for earl grey tea in the Prime Pantry store. I would love to SELECT * FROM products p WHERE p.prime_pantry = 1 AND p.keywords = 'earl grey tea' AND p.packaging = 'bulk' I get that this'll never happen, but man... it'd be nice.
January 5, 2019

more light, better pictures

We were trying to take some Christmas pictures but feeling a bit unsatisfied with the way the pictures were coming out: I wanted some flash or something, but the batteries on all the “better” cameras were already dead, so I went looking for an alternative. We tried to get the overhead light turned on, but couldn’t find the switch for that. The next-closest source of light was a sheet music lamp on my mom’s piano!
  • ««
  • «
  • 1
  • 2
  • 3
  •  … 
  • 19
  • »
  • »»
© traviscj/blog 2020