Transportation 2.0

This post is on drafts now for about 2 years, it’s a concise summary of my Tesla investment thesis. My mental carburetor chocked at AI and autonomous driving… and guess what? I still have a shallow understanding of machine learning, neural nets, PyTorch, TPUs and all the technical stuff to deep dive into the AI stuff. And bear with me this stuff is crucial in my mind rational as Tesla’s business model is like a Trojan horse to deploy autonomous driving.

BUT no way that I could overcome my technical limitations… SO this post could stay in Drafts indefinitely, OR just like a IRL conversation with friends (congrats for the ones that actually invested) just wrap it up, and put out the general ideas to all my friends that unfortunately don’t have the opportunity to meet IRL so often.

Disclaimer: this is just my stream of consciousness, do not to take it as financial advise. DO YOUR OWN research and thinking. This can be the ramblings of a insane mind.

Humans, are quite an unsuccessful species about self conservation. We have a (declared) stockpile of nukes to destroy the total earth landmass SEVERAL times. The most important leader today doesn’t “believe” in climate change, and most of the others humans happily let the poison of the atmosphere, the water and the land to continue despite all the warnings.

Imagine a visitor from another world looking at this madness, probably we would be cataloged as “Technological savvy but totally schizophrenic species”. One must ask what legacy are we leaving to the next generations?

Anyway let’s be optimistic, continue the exercise and indulge into random thoughts and speculations about the future. Look and behold when one day the measure of computer RAM will be not in gigabytes, but in terabytes.

Transportation 2.0

There is a revolution about the way people and cargo move around, probably the Jetsons flying car is not coming around soon (or probably it is in the form of electric VTOLs), but billions and billions are being spent into electrification of vehicles.

And this an extremely good thing, because a big chunk of total world CO2 and pollution is generated by burning stuff inside ICE (internal combustion engines), and the BEV (battery electric vehicle) is so much more efficient that it’s operation is much cleaner. And as the power grid gets greener with more renewables in the mix, the overall gap just gets bigger and bigger.

There are two metrics about batteries that don’t lie, the energy density Wh/L and the cost USD/kWh, and the trend is simple for both, higher energy density and less cost every year. It’s nothing at all like Moore’s law, much slower, but even predicting a very conservative 5% increase in density and 5% decrease in price every year, around 2050 (perhaps much sooner considering the massive resources allocations) BEVs will have the equal energy density at a fraction of cost of ICE. Factoring in the difference in engine efficiency, supply chain, and environmental impact, probably much sooner than 2050 will be the end of the ICE age.

Perhaps in a far future there will be internal combustion engines in museums showing the exquisite materials and craftsmanship of a time that the world was powered by an ordered symphony of tiny explosions. I imagine like something like a starting up and revving up event with all the attendees in highly protective gear…

Sometimes i see this video just for the comic entertainment value:

It’s so funny, this was June 2010, each TSLA share was selling at 17USD (3.4USD split adjusted…). Guess the market had different view… why was Jim Cramer so wrong?

Tip of IcebergBecause he couldn’t understand inside his primate brain that the real transportation revolution is not the transition from liquid fuel to electric. No, that is just tip of the iceberg, the real revolution that’s going to turn everything upside down, it’s autonomous driving.

Think of all business around moving people and cargo, think of all the payrolls for professional drivers, think of all social security for professional drivers, think of all the road fatalities, think ride sharing and no ownership, think of long distance truck hauling, think of your car leave you on the spot and then proceed to park itself, think about drinking a coffee and finishing that report on your boring morning stop and go commute, think about going home drunk with no problem at all, think about catching some sleep on that long journey, think about elderly or disabled people who want to continue to go places by themselves…. etc, etc, etc…. it’s going to be a beautiful new world.

How much does it worth to have a total autonomous car system that can drive better than the top human drivers? That can operate 24/7 and doesn’t get tired, sleepy, drunk, nervous, over optimistic or distracted? A lot, really a LOT.

The race for the jackpot is on, with billions and billions being invested now. And where there is strong competition there will be results, and here Moore’s law is king, so expect this future to be nearer than generally expected. The company in the pole position is Tesla, and if they can deliver first probably they will become one of the most valuable companies in the world, probably the most valuable company in the world as autonomous driving implies solving computer vision, and computer vision achieved unlocks much more than autonomous driving.

Pushing forward deep into the future. We can ask this question, when an autonomous vehicle will be say 10x, 20x, or 100x safer than an average human driving, will human driving in public roads should be even allowed? Guess not, so I bet a lunch in the best restaurant in town with everyone that accepts the bet, that in 100 years from now human driving in Sweden (or Norway) will only be allowed in closed circuits (lets us hope the Nurburgring is still up and running).

AI

1951 First AI program
1956 Los Alamos chess is the first program to play chess
1997 Deep Blue defeats Garry Kasparok
2007 Checkers is solved paper published
2015 Baidu Deep Image outperforms average human in image sorting and recognition
2017 AlphaZero learns chess self playing itself 24h and crushes the strongest chess AI
2017 AlphaGo beats Lee Seedol in the game of Go (10^170 valid board configurations)

as we can see with these few examples the machines are learning, and are learning more complex tasks and are learning faster. As of now machines are already at super human level at many  tasks.

Sure driving is a task that one must parse several complex inputs  (vision, sound, proper acceleration) and compute with context real time outputs (turning, accelerating, braking), but there is nothing magical or physical impossible for a machine to perform, and perform well better than an human.

Assuming hardware will keep improving offering better performance at lower price each year, and computer science AI and machine learning will also keep improving over time, there will be a point in time that these factors will compound and intersect to unlock autonomous driving, and Tesla with silicon valley tech know-how, best engineers in the world,  huge fleet collecting real world data for training the neural networks, own chip designed specifically for artificial intelligence, etc, etc… will be (in my mind) the one company to unlock it first.

According to Tesla 2021 2q safety report, they recorded one crash for every 4.41 million miles driven in which drivers were using Autopilot technology (Autosteer and active safety features). For drivers who were not using Autopilot technology (no Autosteer and active safety features), they recorded one crash for every 1.2 million miles driven. By comparison, NHTSA’s most recent data shows that in the United States there is an automobile crash every 484,000 miles.

Some of the typical questions i have been asked IRL about the thesis:

Won’t legacy auto crush Tesla by sheer volume?
Well if that was to happen, it should have happened many moons ago. Tesla is a big boy now, growing fast with probably the strongest balance sheet in the industry. Besides legacy auto strength is in metal casting and folding, it can’t even put up a decent infotainment system… much more develop an autonomous driving system.

Besides legacy auto is in a world of pain, declining sales, convert factories and human resources to electric powertrains, battery supply, huge debts…. they are giants on clay feet.

OK, but the actual stock value has already risen tremendously, didn’t I missed the boat?
It’s a fact, the stock price already skyrocketed. If you invested 1000 USD back in the IPO and hold it (Jim told you to sell… big shout out to Jim) you would have today around 200.000 USD…

You can make a case to justify the current valuation on current business alone, you can go trough profit margins, growth rates, CAGR, ROI and other financial indicators, you can value Elon Musk as the modern Edison, but for me the equation is simple, if you can envision a near future with autonomous driving with Tesla leading, the valuation is cheap. If you can’t envision this, probably the valuation is more on the pricey side.

I’m not a big fan of reasoning by analogy, but I must also point that for disruptive companies, companies that change the world, with strong leadership and mission, companies that enter a positive loop feedback system it doesn’t make much sense to cap an upper limit.

“In the short run, the market is a voting machine but in the long run, it is a weighing machine.” – Benjamin Graham

PF firewall – Simple IP block

The easiest way to block IP addresses in a system with PF firewall is to create a persistent block table, and then just interact with the table.

In /etc/pf.conf

table <badhosts> persist

set skip on lo0
scrub in all

block in quick from <badhosts> to any
pass all

Each packet is evaluated against the filter ruleset from top to bottom. By default, the packet is marked for passage, which can be changed by any rule, and could be changed back and forth several times before the end of the filter rules. The last matching rule wins, but there is one exception to this: The quick option on a filtering rule has the effect of canceling any further rule processing and causes the specified action to be taken.

OpenBSD PF – Packet Filtering

Load ruleset

pfctl -f /etc/pf.conf

Add addresses

pfctl -t badhosts -T add 1.2.3.4
pfctl -t badhosts -T add 2.3.4.5

Show addresses

pfctl -t badhosts -T show

Delete an address

pfctl -t badhosts -T delete 1.2.3.4

Delete all adresses

pfctl -t badhosts -T flush

And remember boys and girls, 30 minutes poking with commands can save you 3 minutes of documentation reading….

The Virtualbox post

Mainly to myself, my repository of tips and tricks of running Virtualbox under Linux. Feel free to use at your own risk.

Configuration location

/home/$USER/.config/VirtualBox

Connected USB devices not showing up in the usb filter
Check, and add your user to vboxusers group

sudo usermod -a -G vboxusers $USER

Running Guest OS with different date time than Host OS
This is really useful to run old software with time limitations without messing up with the Host OS date/time settings.

It’s easy to specify a time offset from the Host OS in microseconds. 

First get the vm name

VBoxManage list vms

Secondly apply the desired offset (example -1 year clock).

VBoxManage modifyvm "name in vm list" --biossystemtimeoffset -31536000000

(1y = 365d * 24h * 60m * 60s * 1000m)

Getting the feet wet with DKIM

DKIM stands for DomainKeys Identified Mail, it’s an anti-phishing / anti-spoofing system for email that relies on private/public key system to authenticate the origin of the email. Kind of SPF records but on steroids. You can find a pretty concise explanation of the DKIM system here.

I needed to figure this out, as my SPAM (sorry let me just correct this), my outgoing SOLICITED bulk email sending box was getting lower deliverability rates. So it seems having this system helps, because as everybody knows all the lower grade spam senders can’t figure this out.

First thing is to create a private/public key pair. You can go all out with OPENSSL, but as I feel a bit lazy, and not in the mood for man pages and the macho man CLI black magic, just used the online tool that the good people of Worx (the PHPMailer people) provide here.

You must provide the filenames for the pair, just click next, and in the next step fill the domain (pretty self explanatory), the identity (just left blank), the selector, and a passphrase (I left that blank also). The selector is mandatory, as the DKIM system allows to have several keys per domain, it uses the selector to identify which key the email was signed with. Even if you are using just one key per domain you need to assign a value here (I used “default”, but it can be anything like “potato” or “balls”.

You will get a zip file with everything you need, and even some instructions to protect the key files with .htaccess directives, because as the good people of Worx know, PHPMailer is PHP, and all PHP programmers are dummies, so they will happily put the key files under the domain website root and probably with a couple of links from the website homepage.

I bet that somewhere in the support forums somebody asked: why I can’t access my key files, always getting those 403 Forbidden errors.

First thing is to publish your public key on DNS. I use DJB tinydns DNS server with VegaDNS management, the old PHP version when the author placed key files in the public website root. Now he is smart, the 2.0 version is in Python and he doesn’t do this anymore… anyway add a new TXT record for the domain, in the hostname put “selector._domainkey” (change the selector part to the string you defined before), and in the address field put in one line only:

v=DKIM1; k=rsa; p=publickey

(replace publickey with the public key that you get previously). If you are using other DNS server check out the specific documentation on creating TXT records.

Now, to sign the email messages you send. Obviously the natural choice is to have your MTA auto magically sign the outgoing emails. To me that means to mess with my power beast Qmail production installation, this means messing with the macho man stuff, patches, libraries and compilers. Not so good to make a quick fix for sending SPAM (sorry, SOLICITED bulk email). So I went the easy route and use the PHPMailer to sign the outgoing emails.

Just have to add a couple of lines:

$email = new PHPMailer();
$email->DKIM_domain = 'domain.com'; // the domain
$email->DKIM_private = '/path/to/private/key'; // please even using PHP keep the file above the webroot
$email->DKIM_selector = 'default'; // the selector you published in DNS

and proceed to testing. There are plenty of online services that provide us this service. I liked this one. But after doing some testing I quickly realized that something was not well in the DKIM land…

All the outgoing emails were sent with some bad header char. Even sending to my own system, the Amavisd was quarantining the emails with virus suspicions due to a bad header. Further looking into this, just realized that between the last header line and the DKIM signature there was a dreadful ^M (a carriage return, the DOS \n\r not compliant with the email spec). This is in a plain vanilla Qmail running on Debian, and with latest stable PHPMailer.

There was just one thing to do, bring out the old quick and fix hammer and change the class.phpmailer.php file. If you have the same problem in line 1305 change the CRLF to just LF:

/*
$this->MIMEHeader = rtrim($this->MIMEHeader, "\r\n ") . self::CRLF .
    str_replace("\r\n", "\n", $header_dkim) . self::CRLF;
*/

$this->MIMEHeader = rtrim($this->MIMEHeader, "\r\n ") . "\n" .
    str_replace("\r\n", "\n", $header_dkim) . self::CRLF;

And everything is running nice and well.

Raspberry PI sending emails

Using the PI as an headless server doing some stuff, it’s a good thing to have reports by email. The best and easy way is to run sSMTP a very simple program that sends outgoing email to a mailhub for delivery.

You can actually use your Gmail account or any other account (I’m using any other account).

Install it:

apt-get install ssmtp

Configure it at /etc/ssmtp/ssmtp.conf. The most relevant option:

mailhub=mail.domain.com (the SMTP agent host, the “outgoing server” in email clients like thunderbird)

If your outgoing server needs authentication for relaying (probably you do need, if you can send emails to your own domain emails, but can’t send to external emails), set the credentials with these two options:
AuthUser=youruser@domain.com
AuthPass=yourpassword

To test it, i executed the good old mail command but get a no-no response:
-bash: mail: command not found

As Raspbian is Debian based, the “user-friendliness” doesn’t provide these stone age commands to protect one from oneself… so I went kind of mental and install it anyway:

apt-get install mailutils


After this operation, 22,8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

OH BOY, THAT’S A FUCKING LOTS OF MB/PACKAGES/DEPENDENCIES TO GET A CLI COMMAND

mail youremail@domain.com

in the interactive mode, just follow the instructions, write some non-sense to test it and then press CTRL-D to test it. And your email should automagically appear in youremail@domain.com inbox.

If something goes wrong, you can add DEBUG=YES to /etc/ssmtp/ssmtp.conf.