SSH Configuration Checklist

Some basics settings to check in your /etc/ssh/sshd_config to verify it's properly secured.

More →

RRDTool Dataset Generator

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 →

Upgrade Linux Mint (16/Petra to 17.1/Rebecca)

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.

Upgrade

The following steps is needed:

  1. update current system repositories
  2. upgrade current system
  3. change repository sources manually
  4. update current system repositories (as in step 1 but with the new repository sources)
  5. distribution upgrade
  6. upgrade current system (same steps as in 2 but using the new distribution version)
  7. reboot
More →

Power of Curl and OCR

Ever needed to download hundreds of images and run them through OCR to get plain text out of it?

I just did by combine the power of Curl, Bash and Tesseract OCR.

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 →

Re-evaluate PS1 in bash

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.

I'm usint 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 →

The power of pipe and SSH

The concept of pipes in Unix is very powerful. If we combine pipes with tar and ssh we have a simple and secure way of transfering files. It might not be the best way but these are tools that are available on almost any Unix system and it does have some advantages such as not using any space on the source system.

Simple file transfer

From a host you are currently logged on to:

$ tar zcf - source | ssh user@host 'tar zxf -'

From a remote host:

$ ssh user@host 'tar zcf - source' | tar zxf -
More →

Install MonoGame on Ubuntu based Linux

Some short notes on how to install MonoGame on Ubuntu based Linux with as little effort as possible.

sudo apt-get install mono-complete
sudo apt-get install monodevelop-monogame

This should install everything, and then some, to get started exploring MonoGame.

Mono on Linux doesn't trust any SSL certificates by default. Resolve this by importing Mozilla's list of trusted certificates to avoid confusing errors later on:

mozroots --import --sync

Troubleshooting

If running into trouble trying to start MonoDevelop try to start without redirecting stdout/stderr:

monodevelop --no-redirect

Why it gets redirected by default is beyond me since failing without any information to the user is not very helpful. Fail early and fail loudly is a useful rule of thumb and hiding error messages are just bad.

References

More →

Notes on Unit Testing in C# with ASP.NET MVC using NUnit, Moq and Selenium

Some quick notes on unit testing and testing ASP.NET MVC projects.

Tools

The environment and tools used:

More →

Notes on Building C Code in Windows

Just for fun I wanted to make some notes about how to compile a simple C program in Windows from the command line with the minimal of extras to install. If you go looking on the web almost all answers to the question "how do I compile a C program on windows?" is either to download and install Visual Studio Express for Windows (the free version of Visual Studio), to use MinGW or to get Cygwin.

More →

Enhanced hlsearch in Vim

A while back I watched the talk More Instantly Better Vim by Damian Conway from OSCON 2013.

There were a lot of interesting Vim stuff in that talk and the talk it self was entertaining (go watch it).

One of the things I took away from the talk was enhanced hlsearch. When there's a lot of matches it can be kind of hard to see what occurence you just jumped to. This snippet makes the current match flash for a brief period of time.

More →

Python Toolbox

A list of tools and libraries for development with Python.

HW Shitlist

A list of hardware manufacturers that I personally wish to avoid purchasing equipment from and why.