Update: This article now also exists as a git repository.
I played around with MQTT and Python for an upcoming project of mine.
Here are some notes and a simple example code for a subscriber.More →
Some random thoughts about comments and readability on the Internet.
I'm concerened about readability. Whether it's code, fiction, blogs, forums or emails. Take emails for instance. If you've spent some amount of time with emailing lists you have probably learned about the dreads of top posting. (If not you have probably no participated that much in the conversations.)
The same problems that arises in lengthy email conversations persists in comment sections and forums on the Internet. To catch up on the discussion and participate usually involves a lot of scrolling and jumping around. Often the timeline is manipulated or reversed, more often than not there's a lot of clutter obscuring the view of the real content and the signal to noise ratio is high.More →
Reading a write up on commercial games that have been open sourced I got reminded of how much I enjoyed playing the original SimCity back in the day. Since the post pointed out the source code of the Unix port I decided to download and try it out.More →
It is often useful to find out what package a file belongs to. Unfortunately this is dependent on package manager and if you run different systems with different package managers it can be tricky to remember how you find this information for a perticular package manager. So, here's some notes about how to find this information for some package managers.More →
Some basics settings to check in your /etc/ssh/sshd_config to verify it's properly secured.More →
I recently looked into RRDtool again. I realized that everytime I do I end up writing some scripts to create, update and generate graphs just so I can test stuff out.
For example, if I want to graph some temperature metrics I want to create a database, fill it with some mock up data and create some graphs. It's my RRDtool development cycle so to speak.
So this time I wrote three bash scripts to do just this. They are commented and are easy to modify depending on my needs.More →
One of my laptops was still running Linux Mint 16, also known as Petra, and an upgrade was long overdue. This post documents the process I used.
Note: I don't guarantee anything. Linux Mint is a binary dist based on another binary dist (Ubuntu) based on yet another binary dist (Debian). If the upgrade fails you are on your own.
The following steps is needed:
Ever needed to download hundreds of images and run them through OCR to get plain text out of it?
Curl has this nice feature to be able to express ranges in URLs. The images I needed to fetch was numbered so insted of writing a loop in bash and iterating I could just do something like this:
$ curl -O http://example.net/img[1-800].png
Then I simply iterated over each recieved file feeding it to Tesseract:
$ for f in $(ls img*.png); do tesseract $f $(echo $f | cut -d'.' -f1) -l swe; done
This produced a nice bunch of text files with the same as the image scanned and with the suffix txt.
Of course I could have done it all in the shell loop but it's nice to know the tools you use and for just fetching a bunch of URLs it's easier and more readable than creating a tiny shell script.More →
This is a little gem I found out when I changed my PS1 expression to include a counter for my todo list items in my prompt.
t to organize my tasks and took the PS1 suggested on the site:
export PS1="[$(t | wc -l | sed -e's/ *//')] $PS1"
I soon found out that it only gets evaluated once when bash starts. The trick, it turns out, is to escape $ so that it gets interpreted literally when bash starts but then gets used as expression when PS1 is re-evaluated:
export PS1="[\$(t | wc -l | sed -e's/ *//')] $PS1"
So this, the tiniest possible change, got me a nice, live, task count showing in my prompt. A nice reminder that I still have work to do.More →