Minimum Functions in C Compared

Anyone who has written C code has probably at one point or another had to write a small function to find the minimum value in a set of integers. When the set contains only two numbers, a macro like #define min(a,b) ((a) < (b) ? (a) : (b)) is frequently used. When the set is expanded to three it is possible to add to that macro, but I generally prefer to err on the side of code readability whenever possible, so I just write a little function to do it. Recently, as I was performing research for my master’s thesis, I saw some C++ code which implemented the minimum_of_three function slightly differently than my standard naïve approach. The comment said something to the effect of, “spend a register to reduce the number of branches and increase performance.” I’m always looking for ways to improve my code, so I thought that I would try out this better way. However, I am not one to just blindly believe stuff I read in code comments, so I had to test it out for myself. Below are the results of my analysis.

JavaScript Simple-12 Simulator

The other day I posted the simple microporcessor design that I created as an undergraduate. As a part of that project I also had to write an assembler and simulator for the processor. Way back in 2011, when I was working on this project, the Hipster movement was nearing its peak in the US, and I had to find a nerdy way to get some irony. I decided it would be awesome to write the assembler and simulator in JavaScript. So, for those of you who want to run some Simple-12 programs online, check out my web-based Simple-12 simulator. Below are some sample programs.

Simple Microprocessor Design

Simple Microprocessor Design

This details the hardware design for a simple 12-bit microporcessor. I created it for an undergraduate class which I took a few years ago. It is not really usefull for anything besides learning how computer hardware works, but I still think that it is pretty cool. I found the documentation for it on my hard drive and remebered how proud I was to have actually completed it; I am a computer scientist, not a computer engineer. Simple logic gates are used as the basis for the creation of more complex digital electronic circuits; those circuits, including a control unit, are in turn connected via a datapath to form a completed processor. The processor datapath is designed to implement the Simple-12 instruction set.

fuzziac.js : Approximate String Matching in JavaScript

Fuzziac.js is JavaScript class for on-line approximate string matching. It was originally intended for use with auto-complete, such as that provided by jQuery UI. This is started as a research project for an undergraduate algorithms class which I took way back in 2011. We had to complete a term project on an algorithm, and Dr. Duan made dynamic programming look cool, so I though I would look for an application of dynamic programming outside the realm of DNA sequencing.

Where I was working at the time I had been updating web-based intranet applications to use RESTful services and shared JavaScript libraries; one of the most popular updates I made was to add auto-complete (thank you jQuery UI) to all the person name fields across the various applications. I worked for a multi-national and culturally diverse company, so spelling people’s names right was a big problem (e.g. Is it Lucy Lu or Lucy Liu? How do you spell Lakshmi Yaragudipati? Jake Bruder’s real name is Joachim Bruder; who knew? etc., etc.). Previous attempts to provide normalized person name data relied upon entering employee IDs, but no one knows anyone else’s employee ID, so they would always have to look it up. Or, if there was no penalty for entering the wrong employee ID, people would just enter their own, which made the results of data analysis faulty. I knew that in order for the data to be correct it would have to be easy for users to enter it correctly, and this problem seemed to be a good fit for a dynamic programming approach.

Objective-C: Post- or Pre- Increment?

I have heard that it is more efficient, in C based languages, to pre-increment (++counter) than it is to post-increment (counter++). However all the online discusions of the topic that I have seen did not provide actual evidence as to why that might be. One of the things I have learned about technology is that there are very few rules of thumb that last, especially when it comes to limitations. So, I decided to run a couple small tests using my current language of choice, Objective-C.

Let’s start with the most basic example. We will define an integer, post-increment it, pre-increment it, and then look at the generated asembly code. I entered the following Objective-C code into Xcode. (By the way, using int instead of NSInteger will produce the same results, but Apple recomends using NSInteger since it is a 32-bit int on 32-bit platforms and a 64-bit int on 64-bit platforms)

NSInteger i = 0;

City of Barberton, The App

The Mayor of Barberton, William Judge, is always looking for ways to engage the community, and I have been working with him to accomplish that on the technology front. In 2013 I did a complete overhaul of the City’s website; the goal was to structure the website in a way which would make it easier for citizens to interact with local government while also promoting the City’s strengths to visitors and potential residents. The website was designed with mobile use in mind, but people are coming to expect the experience provided by a dedicated mobile apps, so in 2014 Barberton will begin introducing dedicated mobile apps.

MarkShown Version 2.0

MarkShown is a very simple iPhone app for quickly creating textual presentations which can be shown on an external display. Markdown syntax is used to format presentation slides and presenter notes; the presentation slides will show on an AirPlay device or other attached display, and the presenter notes will show on the local screen.

Version 2.0 of Markshown is now available in the App Store. This version uses Discount 2.1.6 to parse the Markdown, so it does SmartyPants transformations and supports other Discount specific syntax. Discount takes Markdown and generates HTML, so UIWebViews replaced UIViews with CoreText. This means that CSS can be used to style the presentations, and the style portion of the app is now nothing more than CSS. Since each slide and presenter note is essentially a web page the navigation was changed to act like Safari, swiping left from the right edge navigates to the next page and swiping right from the left edge navigates to the previous page.

Bugzilla Details Script

I recently worked on a project which required extracting bug details from a Bugzilla database; we were attempting to reproduce the results of an academic paper in which the authors attempted to establish a link between object-oriented software metrics and program buginess. Bug data was obtained from a Bugzilla database to determine the buginess of a class. The original authors obtained a copy of the entire bug database and ran queries against it directly. We would not have been able to get a copy of the entire database, but fortunately it is now available on-line. We started by using the Bugzilla web search interface to get a list of bugs for the time period covered in the original research. We then fed that list of bug IDs into the script below to get the details we needed: which files, or classes, were associated with each bug.