Building your own more expensive Nest: Arduino, Android, React Native.
I recently bought a used Fiat 500e, naturally I set out to reverse engineer the CAN bus in it. That led me to discover Arduinos (which I knew existed but had never used) as well as ESP8266s. I had previously used FHEM to wire up my heater in Germany but it felt outdated even in 2011, much more so now so I decided to go for something prettier.
I first build a prototype on a breadboard that could connect to our wifi and control the heater. The Arduino acts as a temperature sensor as well as a way of switching our heater on. It however does not implement any control mechanism, instead it subscribes and publishes to an MQTT server and the actual control-loop is implemented using Node-RED. This seems beneficial as it is much easier to maintain software on a Linux machine than OTA updating an Arduino. Also, it allows leveraging cool plugins available in Node-RED.
Reverse-engineering exact location information through trilateration.
Many datasets on the internet accidentally expose location information by allowing distance based search (“find everything within 3 miles around this point”) from arbitrary points of origin. I happened upon such a dataset and wanted to try rediscover the original location through trilateration.
Trilateration, which is commonly wrongly referred to as triangulation, is the
process of finding a location L
given three other locations A
, B
, C
and
their distance to L
(let’s call that dA
, dB
and dC
). Very surprisingly
to me, I was not able to find a lot of good, sure-fire solutions to this easily
when I wanted to solve a trilateration problem so there’s a summary of what I
found.
Automating allocation reports in Ledger.
Motivation
If you own any stocks or funds you probably want to track the allocation, meaning how much money is in stocks and funds respectively. Some fairly well known low key investment strategies rely on balancing this ratio, for instance this one.
In Ledger, allocations can be modelled easily through allocation based accounts and automatic transactions. This is outlined here. If you do this however, you still have to manually update allocations for every fund you own which is a nuisance, especially if you own something like a target retirement investment fund which naturally and purposefully changes its allocation strategy over time.
Automating commodity prices in Ledger.
Motivation
If you use Ledger CLI, chances are you will use more commodities than just dollar. This is actually one of Ledger’s best features. For instance, I track our 401k in Ledger and it allows me to list the ticker symbols of the funds we have purchased inside the 401k as well as the fact that this is pre-tax money. Our opening balances look something like this:
2016/07/19 * Opening Balance
Assets:Checking $200.00
Assets:Investments:401 3.1 VFIFX @ p$29.8
Assets:Investments:401 2.5 VTTSX @ p$29.8
...
Income:Opening Balances
Roughly, this means that we have two different funds in our 401k with ticker
symbols VFIFX
and VTTSX
respectively. Also, the funds are not valued in dollars but
in p$
which is our commodity for pre-tax money. The idea is that this money,
if accessed today, has a much lower actual value because we’d have to pay
federal, state and penality taxes on it. Therefore, the price database for
this looks like this
Loading Chase.com transactions into Ledger
When trying to migrate away from Mint to Ledger, one of the major obstacles is automating the work of entering every 3 dollar coffee shop transaction manually. Ledger does provide some help in this area through the use of ledger xact, yet as of today, we enter 25 transactions per week into ledger and a large chunk of them is from our Chase credit cards. Automation seems to be the easiest way to make this a lot less painful.
Command line accounting: From mint.com to Ledger.
I’ve recently switched all my families accounting from manually looking at bank websites + mint.com to Ledger. This post describes the first part of that fairly long but ultimately successful journey: Motivation and Challenges.
Motivation A: If your bank dropped $1,000 from your account, would you notice?
I think my dad would have. He had all statements printed. In Germany, you do this at a small machine in the bank building (or you have the printouts mailed to you) and by putting them into a folder, you see old and new balances as well as the transactions between the two. This presumably makes spotting that something is off fairly easy.
Parsing expressions
Expressions occur naturally in many languages, for instance in SQL. Usual ways of executing expressions are by interpretation or code generation. While I want to eventually talk about code generation, a sensible first step approaching expressions is parsing them from text which I will discuss in the blog post.
Looking at a SQL statement, we find multiple expression but will first focus on the one used to find qualifying tuples which comes after the WHERE
keyword:
C Mythbusters: Counting up vs. down
A while ago, I stumbled upon a guide to writing optimized C code. I had read a few of the ideas before and previously discounted them as “something the optimizer should really do for you”. In this and the next few posts I will take individual pieces of advice and fact check whether rewriting your code as suggested actually helps or not.
Let’s start with a simple proposition: Counting down to zero is cheaper than counting up. A similar proposition is sometimes encountered which this post will investigate as well: Comparing != (not equal) is faster than < lower than in a loop.
H1B: Things to Remember
I am trying to write down everything that I remembered to do before leaving for the US so that posterity can benefit from it. I will add what I forgot later on.
DMV Report, Car insurance report
I have requested a report from my file with the Germany equivalent of the DMV just in case. I also asked my car insurance provider to send a letter stating that I am in good standing with them and have not had them pay for anything in the last 11 years. Apparently, some auto insurance carriers in the US will give you a discount if you can provide such information but no matter if useful or not things like this are easier to do before leaving.
SSH into Docker containers by name
I hacked together an SSH proxy so that you can direct SSH into docker containers using their name. It’s on github, excerpt from the README:
Allows connecting to all your local docker containers using ssh simply like this:
ssh container-name.docker
if container-name is the name of the container and ssh is running in it. Automatically install for the current user using
curl -s https://raw.githubusercontent.com/henrik-muehe/docker-ssh/master/install | /bin/bash
Enjoy!