traviscj/blog

Posts

January 3, 2018

everything has a failure rate

I was happily riding in to work this morning on my motorcycle. Periodically while riding, a spark of terror that I’ve forgotten to buckle my backpack to the bike’s frame hits me. So frequently, in fact, that I’ve grown used to reaching behind me to feel for the backpack in a spare second when I don’t need to clutch.

Today was different:

I reached for the backpack but felt nothing.

read more
January 2, 2018

extracting the last few dollars from Visa/MC gift cards

Once in a while, I get a prepaid gift card like this:

They’re – like money – great! But they do have one downside: it’s hard to spend the change once you’ve bought off most of the value.

Originally this was going to be a quick “just redeem it with Amazon’s gift card” post, but a bit of study revealed that it isn’t quiet that simple:

  1. the authorized amount can prevent the full transaction from going through, so if it’s the first transaction at Amazon, you might need to leave $1.00 to cover the reserve.
  2. the article mentions a $5 minimum, but the initial amount & card selection on Amazon doesn’t seem to have a problem with lower amounts, so YMMV I guess.

The article also mentions a different solution that I should have thought of: apparently some banks will redeem the value of the card into your account. You just need to show up at a branch of your bank with proper identification.

read more
January 1, 2018

things you don't learn in grad school

  1. oncall exists.
  2. the data is never available how you need it.
  3. unit tests matter.
  4. pushing code after 3pm is risky if you’re not willing to work all night. (courtesy Paul Joos)
read more
November 29, 2017

url encoding safe relational operators

I was catching up on Jesse Wilson’s blog this morning, and in particular his post URL Encoding Is Material. In that article, he says

My advice

If you’re defining your own URLs, you’ll save a lot of trouble by avoiding characters like <, >, {, }, +, ^, &, |, and ;.

I came across this problem in one of my projects at work: I wanted a page to display some recent records with 1) a name field provided by the user and 2) a value field that match $l \leq \text{value} \leq b$, where $l$ and $b$ are given by the user. I also wanted that page to have a URL representing that condition, so that it could be easily shared with teammates and soforth. When I started working on it, I didn’t have Jesse’s wisdom, and so I naively came up with a URL structure something like

read more
November 13, 2017

snack buying

I got this text message from my father-in-law:

Ok. Soda 1.50 Chocolate bar 1.00 Gum 0.10 Jelly Bean .05

Have to buy exactly 14 items and spend $10

At least one of each.

There are 4 diff combos. (Order: soda, chocolate, gum and jelly bean)

Got 5-2-3-4 3-5-4-2

Can’t get others. Any ideas? :)

I whipped up this solution to check in python:

#!/usr/bin/python3
# created_at: 2017-11-13 13:53:19 -0800

def main():
    solutions = 0
    for si in range(1,7):
        for ci in range(1,11):
            for gi in range(1,101):
                for ji in range(1,201):
                    total = si*150 + ci*100 + gi*10 + ji*5
                    items = si + ci + gi + ji
                    if total == 1000 and items == 14:
                        print(si,ci,gi,ji, total, items)
                        solutions += 1
    print(solutions)

if __name__ == "__main__":
    main()

The core of this solution is the check

read more
November 7, 2017

even the ceo doesn't get an office

Square is a fantastic place to work, and has been for my entire time here. One thing I’m not such a fan of, though, is the open office layout we have – and share with many other startups.

Somehow I have the distinct memory of thinking, “Wow, even the CEO doesn’t get an office here! That’s really cool!” I had an important realization today, though. It’s not that the CEO of companies with open offices don’t get an office – it’s that they don’t want one.

read more
October 27, 2017

500 Million Dollars!

I watched Destin’s $500 Million Dollars video:

and had a few thoughts:

my highschool CS education

My highschool had computer teachers, but no computer science teachers. Luckily, we did have a teacher (Dick Van Kirk!) that was willing to sponsor an independent study of some computer science topics. I read the AP Computer Science A study guides and a bunch of the Java: How to Program (Deitel & Deitel) book and managed to get through the AP test with a top score. This enabled me to skip over the intro CSE142 at University of Washington.

read more
September 12, 2017

confident women are getting bypassed by overconfident men

Really interesting youtube talk: confident women are getting bypassed by overconfident men

read more
August 31, 2017

python attrs

I came across a very interesting library in a HN thread: the python attrs library.

In particular, this seems like a great way to do the “dumb data objects” they talk about in the end of object inheritance, and also related to (but maybe lighter weight than) zope.interface.

This also seems very similar to what I use autovalue for at work.

One particularly interesting application is a “code database” – using static, checked-in-to-version-control definitions of some data model as a sort of very-fast-to-read, very-slow-to-update “Data Model”. I find this fascinating: Code shares a lot of properties with great data stores: ability to rollback (git revert) and accountability/auditability (git blame). It also makes a lot of fairly hard problems much simpler: you don’t need to poll the database for changes. You don’t need to invalidate any caches. You don’t need to consider a “split brain” environment where half of the in-memory caches have updated but the other half haven’t. You don’t need to consider failure cases of how long the in-memory cache is allowed to be invalid: you just fail to boot up on deploy. (Admittedly, there’s still an opportunity window for split brain behavior for the duration of the deploy, but this is a lot easier to reason about than an essentially arbitrary.)

read more
July 17, 2017

klr650 planned upgrades

I’m planning on “civilizing” my KLR650 just a tiny bit, since it is coming up on 1500 miles and I haven’t made it offroad at all yet.

There are two (fairly minor) issues with the stock setup, as far as I’m currently concerned:

First, I’d prefer the gearing to be just a little bit taller so I don’t have to wind it up quite as much. The engine just runs a little faster than I’d like at freeway speeds, and even driving around town it just feels slightly off. So I’m thinking about swapping out the stock 15T countershaft sprocket for a 16T. That changes the final drive from 2.87 to 2.69, and saves about 400 RPM at freeway speed, which doesn’t sound like much, but should quiet it up nicely. I found a website called gearingcommander that allows all of these calculations pretty nicely.

read more
  • ««
  • «
  • 3
  • 4
  • 5
  • 6
  • 7
  • »
  • »»
© traviscj/blog 2025