debugging internet
My standard plan for debugging internet connections:
-
Can we reach stuff from some other device?
Usually, connection problems are something like “My iPad isn’t working,” which is caused by a flash of light in the sky, like when Swamp gas from a weather balloon gets trapped in a thermal pocket and reflects the light from Venus."
So try something other than your iPad on your WiFi to isolate whether it is a WiFi network problem or a “iPad"problem.
don't poll
A while ago, I wrote down a list of clever life rules in my day-to-day notebook. One of them was “don’t poll”. To say a bit more about it, don’t spent time waiting for things to finish and checking them constantly.
A more concrete example: I find myself running terminal commands that take ~5 minutes, and then wasting ~5 minutes watching them. This is pretty stupid. So what I have started doing instead is run something like
$ some_long_command
[ ... scroll scroll scroll ... ]
[ ... waiting for it to finish ... ]
[ ... give up ... ]
terminal-notifier -message "some_long_command done"
[ ... go do something else ... ]
logging
In grad school, I spent a lot of time writing code that read output from nonlinear optimization solvers, and tried to do useful things with it. A much better way to do that is called “structured logging”, an idea I experimented with a bit during grad school. It has also been coming up in my working life, so I wanted to delve into it a bit deeper. For a quick introduction, check out Thoughts on Logging. For a lot longer introduction, see The Log: What every software engineer should know about real-time data unifying.
Switching to jekyll
I spent a few hours this evening switching everything over from tcjblog to Jekyll. I really do miss a few parts of the old blog setup, but one of the main reasons I switched several years ago was LaTeX support. Back then, we didn’t have really sweet options like MathJax. And it just takes too long.
One of the other big things that was keeping me from updating the blog the last couple of months was… the stolen laptop. It turns out that I didn’t have very good backups for the last few website updates, which meant that I needed to manually restore blog posts from the website.
14 vs 1499 vs 15
Sometimes, it is tempting to see 14.99 and say “about 14,” even though we all know better. The problem with this is that by giving a 0.07% discount (14.99 vs 15), they have made you estimate a 7% discount (14 vs 15).
Nice trick!
launchd as cron crash course
insert
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.whatever.five_after</string>
<key>ProgramArguments</key>
<array>
<string>echo just ran > /tmp/whatever_five_after</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Minute</key><integer>5</integer>
</dict>
</dict>
</plist>
into $HOME/Library/LaunchAgents/com.whatever.five_after.plist
If you call a script in the ProgramArguments section, remember to make it executable and define the script properly.
Run
launchctl load $HOME/Library/LaunchAgents/com.whatever.five_after.plist
launchctl start com.whatever.five_after
Can also run every N seconds with
<key>StartInterval</key><integer>N</integer>
Can also check the status with
black box machine learning
During my Ph.D. I studied optimization algorithms. Optimization algorithms are typically an integral part of machine learning algorithms, and we discussed many machine learning algorithms, but somehow I made it through without doing very much actual machine learning training or prediction tasks.
It turns out that it isn’t very hard to do some very basic machine learning:
pip install -U numpy scipy scikit-learn
ipython
from sklearn.ensemble import RandomForestClassifier
from sklearn import datasets
iris_data = datasets.load_iris()
rfc = RandomForestClassifier()
rfc.fit(iris_data['data'], iris_data['target'])
rfc.predict([6.1,2.6,5.6,1.4]) # yields array([2])
rfc.predict([5.7,4.4,1.5,0.4]) # yields array([0])
mnemonicode-0.73
I found a really cool tool called mnemonicode.
It basically encodes an arbitrary string into some easily-sayable and understandble phrases:
Traviss-MacBook-Pro% echo "hello world" | ./mnencode
Wordlist ver 0.7
square angel stone. blitz pacific tango. zebra shave basic
Traviss-MacBook-Pro% echo square angel stone. blitz pacific tango. zebra shave basic | ./mndecode
hello world
piping for fun and profit
I recently discovered something pretty cool: groovy, and in particular groovysh. It lets you do cool stuff like run JVM functions:
➜ ~ groovysh
Groovy Shell (2.3.3, JVM: 1.8.0)
Type ':help' or ':h' for help.
-------------------------------------------------------------------------------
groovy:000> new Random().nextInt()
===> 909782845
But the sad part is that it seems pretty slow on my machine:
➜ ~ time (echo :q | groovysh)
Groovy Shell (2.3.3, JVM: 1.8.0)
Type ':help' or ':h' for help.
-------------------------------------------------------------------------------
groovy:000> :q
( echo :q | groovysh; ) 16.56s user 0.31s system 201% cpu 8.384 total
That’s more than 8 seconds just to start up and shut down a prompt that I might just run one command in!
SSL Cert Reissue
Like many others, I have been hit by the heartbleed bug, which kinda sucks. I don’t use SSL for anything very critical, but I do use it at [tcj.io tcj.io], my “projects” website. My host, Linode, has done a great job of providing tutorials on how to deal with the situation. The obvious first step (a couple of days ago) was to upgrade openssl itself:
apt-get update
apt-get upgrade
But this only prevents the server from leaking keys going forward. Since the vulnerability was in the wild for quite some time, I thought it prudent to reissue the certificates as well. Now that I had a bit more time, I went ahead and did a reissue to make sure that nothing going forward gets leaked. This is (as usual) a bit annoying, because of the verification procedure at [Gandi gandi.net]. Otherwise, they’re pretty solid though, so I guess I’ll give them a pass on this one. And they did allow a reissue without revoking, so that’s a good step!