2016 Reflections

31 December 2016

What I did in 2016:

Postitives:

  • I coded!
  • My python knowledge has improved.
  • I contributed a small amount to open source.
  • My command line skills have improved.

Negatives:

  • I did not have a focus. I split my time among coffee script (hubot), wordpress and python.
  • The time spent on hacker rank distracted me from doing another project.
  • Nothing gets done in December. It is all illness and family functions.

What I can do to improve in 2017:

  • Focus on projects. Come up with a plan on what I want to work on and stick to it.
  • Pick a language to focus on.

Happy New Year!

Read More...

On deleting code

29 November 2016

This blog post is my journey on creating, debugging and deleting a unit test.

A frequent choice every programmer faces is whether a piece of code belongs in a program. I was working on a hobby project recently where I faced this choice. I had written a number of unit tests and after some reflection deleted one of the test to improve my code quality. At first read this sounds counter-intuitive. Don’t unit tests improve code quality? Generally, yes they do. But good unit tests need to be repeatable, maintainable and quick to run.

In my case I had created a Trie and some unit tests to validate it. In my test code I created a small Trie which contained 11 entries. However, I wanted to test against a larger set. So, I decided to use the dictionary file in /usr/share/dict/words.

I created the following unit test:

Read More...

How to view a web page on a mobile device from a server running locally on my computer

24 October 2016

When developing a website, I like to run it locally on my computer. This allows me to quickly see the changes I have made. But running the web server locally means I cannot view it on my mobile. How do I solve this? By setting the web server to listen on 0.0.0.0 instead. Now I can see my work from my mobile! But what is 0.0.0.0? Let’s explore.

Read More...

Application Monitoring On A Raspberry Pi

29 September 2016

One of the things I use my Raspberry Pi for is to run a twitter bot. I want this bot to run without much manual intervention. So, I want to be notified if it encounters any errors or is not running. To do this I use Papertrail and Dead Man’s Snitch. I use the free tier plan for both services.

Read More...

6 ways to compare two files on Linux

20 August 2016

Comparing two files is a common task. On my MacBook I use the FileMerge (opendiff) app, which is part of the XCode tool-set. However, there are times when I am at the Linux command line and need to compare two files. In this blog post I will show how to compare files at the command line and with the emacs and vim editors.

Read More...

Solving Perl locale issues on my Raspberry Pi

17 July 2016

On my Raspberry Pi 3 I would get locale warnings when using Perl commands. This blog post explains the steps I took to fix these warnings.

Read More...

Error: package architecture (arm) does not match system (armhf)

11 July 2016

I installed a beta version of a Debian package on my Raspberry Pi 3 and received the following error:

dpkg: error processing archive remote-syslog2_0.18_arm.deb (--install):
package architecture (arm) does not match system (armhf)
Errors were encountered while processing:
remote-syslog2_0.18_arm.deb

The suggested solution was to add the arm architecture as follows:

dpkg --add-architecture arm

and then re-run the install command:

dpkg -i remote-syslog2_0.18_arm.deb

I did so and the package installed and worked as expected. However, this made me wonder:

  • What did the dpkg --add-architecture arm command do?
  • What were the consequences of running that command?

After several hours of reading, experimenting and writing this blog post, I think I know. I’ll start by breaking the command down.

Read More...

Using Hubot with slack

02 June 2016

I have been playing around with hubot and slack. This post describes the steps I used to setup a hubot that uses the slack adapter.

Read More...

Get twitter t.co URL length using Tweepy

15 May 2016

The twitter documentation indicates that t.co lengths can be obtained from the help/configuration API. This post gives an example of how to use the Tweepy Python library to obtain those values.

Read More...

Cron and Python virtualenv

20 April 2016

I created a simple twitter bot that consumes data from a REST API and tweets on certain conditions. The data from the REST API changes infrequently so the bot is set to run every half hour. The bot is written in python and uses a virtualenv so the crontab entry needs to use that virtualenv as well. This post describes what I did to achieve that.

Read More...