Author Archives: Mirkules

Hacker News – Initial GUI

In the previous post, I ran through the installation of Visual Studio and loading a sample project. The post ended with a minimal GUI mock-up for a very simple Hacker News front-end:


It’s basically just a few links that come from a RESTful API on the web, which will allow me to get familiar with VS and C#.

Anyway, starting out with a brand new project, the IDE looks like this:



The biggest problem so far has been documentation. Searching for “making restful calls in C#” on the internet yields many results, and it is really difficult to tell what is still current and what is outdated.

Apparently, there is something called “Nuget” which downloads libraries and links them to your VS solution. One of these libraries is Microsoft.AspNet.WebApi.Client that is needed to call restful APIs on the internet. This post in particular is handy:

Visual Studio for Front-End Development in 2018

Visual Studio, my high school sweetheart. It’s been a long time (>10 years) since I’ve even installed it, and after growing tired of the promise of the alleged awesomeness of HTML5 and all the mushy front-end web frameworks, I decided to look at Visual Studio again. WinForms are not so bad, right? I cut my teeth on Visual Basic 3.0 in middle school, and I fondly look back on those memories.

Visual Basic 3

The new Visual Studio journey will be documented here, from installation to app, through the eyes of two decades of corporate experience in everything BUT Visual Studio and Windows. I don’t even have an application in mind, I just want to play and explore (and maybe get an idea along the way). Since we are seeing Microsoft attempt to turn their image around into a user-friendly, design-friendly, open-source friendly (hello GitHub!) corporation, it will be an interesting experience.



Grab a copy from Which version do you need? Community, Professional or Enterprise? No idea. Typical Microsoft. Anyway, let’s go with the free Community Edition.

Installation is self-explanatory, I just picked tools I thought I needed, weighing in at 30+ GB of download (!)

First Run

After creating a project (C# -> Universal Windows Platform), the IDE complained that Windows needs be upgraded to Update 1083 to view the layout. Sigh. Another lengthy activity.

Sample Tutorial Project

Microsoft has a tutorial about creating a simple interface, and adaptive layouts. The code is shared on GitHub. Cool.

Be careful, ARM architecture is the default build target. I’m running on x64.

The tutorial calls for the app to be run on a device emulator, for example Windows Mobile, but VS doesn’t have that option. Instead, it has “Simulator, Local Machine, Remote Machine, Device”. Simulator doesn’t ever start up properly. Local machine is the only one that actually starts the sample app. “Download new emulators” brings me to a page where only Windows version emulators are available (no mobile devices).

After an hour or so of fiddling, many hours of downloading, I cannot even run the sample application the way Microsoft intended in their tutorial.

Fine, at least I can still run on “Local Machine”. Let’s look at the code.

The first thing that jumps out is:
The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)

Using System Error

Bonus: the error text cannot even be selected with the mouse.

Ugh. These errors are everywhere. According to this SO post, clean the solution and restart VS. This seemed to work.


After a rocky start, we are ready to make a user interface. Let’s start by implementing a Reddit-like interface for Hacker News and iterating over it.

Next post, I’ll explore a very simple interface as seen below, with the ability to read from the official HN API.


Email and Spam Filtering

Have you ever signed up for an online service and suddenly started experiencing a surge of spammy marketing emails? The kinds of emails that are sent directly to you as part of a “customer retention” program after you buy an item like airline tickets, the ones that keep sending you emails about limited-time offers and credit card deals long after your purchase is complete?  Here I’ll discuss some strategies to deal with under-the-radar spam.
Continue reading

Simulating Low Disk Space in iPhone Simulator

While testing my iPhone application, I realized there is no way to test out my worst-case scenario, when there is no disk space. How do we do that? This StackOverflow post lays it out conceptually:

I bet you could also create your own .dmg file with file system of size … say 2Mb and write to it. If this works, then it is super-easy for testing – you just mount it and switch the path for testing. If the dmg is small enough, you could probably even upload it to the source control.

Let’s do this “in practice”.

Continue reading

ASIHTTPRequest vs. NSURLRequest

Support for one of my favorite libraries, ASIHTTPRequest, has been discontinued. I have been slowly but surely making a transition from ASIHTTPRequest (back) to NSURLRequest in some of my projects. I picked ASIHTTPRequest over NSURLRequest because NSURLRequest is verbose. Extremely verbose. ASI also has queueing control, throttling control and much, much more. These are are just some of the things that made ASIHTTPRequest such a pleasure to work with. Alas, I am stuck with NSURLRequest again…

Anyway, one of the more interesting aspects of connection handling is session control. I rely on the backend server to set a session cookie when I log in, and to keep that cookie alive while I do other stuff in the program. But in particular, when I transitioned the login screen to NSURLRequest, I noticed that, despite logging in successfully, my program would think that I’m NOT logged in, in the parts where ASIHTTPRequest is still used. It looks like ASIHTTPRequest is blind to the session cookies that are set using NSURLRequest.

I should also mention that I’m using CodeIgniter on the back end for session control, but in theory it shouldn’t matter (spoiler alert: but it does).

Let’s line up the usual suspects and try to figure out why this happens.

The Usual Suspects
Continue reading

MySQL Exclusive Row Relationships

This post will explore how to find exclusive row relationships — rows that may be grouped together by some non-unique id that identifies some kind of grouping of those rows. For example, let’s say that we are managing a team of players, and that each team has to be unique. In other words, players A and B form Team 1, but players A,B,C form Team 2. Searching for existing teams with players A and B should only return Team 1, searching for teams with players A,B,C should return only Team 2, and searching for B,C returns an empty set. How to do this in SQL?

Continue reading

Stack from Queues

Ran across a question on how to implement a stack by only using queues on SO, so I decided to give it a go in Java and PHP. It’s actually pretty straight forward:

  • Initialize two queues.
  • On every push operation, if both queues are empty, add to the first queue.
  • If one of the queues is full (one will always be empty), pop off all the elements from the full queue and add them to the empty queue in the same order (as they were popped). This guarantees the full queue will always be sorted like a stack, so when a pop occurs, it is popped in the “LIFO” order, not “FIFO” order.

Code after the break. Continue reading

Camera Controller Finished Box

Arduino Camera Controller

The Arduino Camera Controller project was my first Arduino project, one that sparked my interest in electronics. The objective of this project started by building a sensor-triggered camera controller, similar to the amazing Camera Axe. I followed that project for two years, and it is truly amazing what he/she was able to accomplish with it (as far as I can see, that project can now be considered a professional product). This was my starting inspiration; I wanted to build something that could activate my Canon Rebel XTi from a sensor, and also have the option to take a series of photos for use in a time lapse video. This writeup is how I got from zero knowledge of electronics and mechanical engineering to a (nearly) finished project.

Camera Controller Finished Box

Camera Controller Finished Box

Continue reading

Doubly Linked List in C

Revisiting some of my old Arduino projects over the weekend, I remembered that C is not my strong point (that was almost a pun… close call). Rather than run away from the mountain of ampersands and hail of asterisks that ensued, I decided to improve on my Canon Rebel remote control project (loosely inspired by the awesome Camera Axe) by redoing the menu system for the Arduino-controlled LCD.

I will do the project write-up at another time as this post is largely aimed at higher-level language people like myself who struggle with pointers and memory addressing. But the good news is that there are a lot of tutorials and examples online for linked lists and various data structures in C. Continue reading

Dijsktra (in Prague)

Piggybacking onto my previous post about graphs and DFS and BFS, you may have noticed there is also a weight assigned to each edge in a graph. This is because I will talk about path-finding algorithms, starting with Dijsktra’s Algorithm. There are plenty of resources online, such as Wikipedia’s Description that do a fairly good job of describing the algorithm.

However, none of them explain the algorithm in a real world scenario, so I decided to describe it using a city whose beauty was distracting to my path orientation, causing me to constantly get lost: Prague, Czech Republic.

Graph of Prague

A section of Prague with a graph overlay

If you were planning a trip in a few blocks of that intersection, and all you had was this map, how would you get from, for example, point P to point W? Intuitively, you would look at A and all edges connected to it (without using an illustrated map, i.e. from a table), pick the lowest one and repeat.

Here is a PDF of Dijsktra’s Algorithm in Action and an animated GIF.

Dijsktra Animation

Dijsktra Animation

And finally, the updated code in PHP.