Make An UIWebView Transparent

I’ve been playing around with iOS. One challenge I came across was how to make a Web View transparent. I found two ways to do this: using the Interface Builder in Xcode or using Swift.

Read More...

3 Things I learned from the Introduction to Mathematical Thinking class

I took the Introduction to Mathematical Thinking class to improve my logical thinking. I found the class difficult, but I enjoyed it. The class covered many topics including truth tables, number theory and real analysis. The following are three things I learned that I can apply to programming or every day life.

1 - Understanding versus solving a problem

When faced with a problem it is natural to want to dive in and solve it. However, it is important stop and examine the problem. Is there a pattern? Does everyone have the same context for the problem? Is there ambiguity about the requirements?

Mathematical thinking focuses on understanding a problem rather than rushing to solve it. This is because finding the answer solves that one problem. But, understanding means the solution can be applied to many problems.

One example from the class was to find the double meaning in the following statement:

Read More...

I'm taking a math class

I’m starting 2017 by taking Coursera’s Introduction to Mathematical Thinking class. In my previous post I noted I should focus on programming projects. I realize I am distracting myself from that goal. However, I am taking this class for the following reasons:

Read More...

2016 Reflections

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

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

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

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

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

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)

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...