1,000,000 Concurrent Connections

I hear the misconception that a server can only accept 65K connections or a server consumes a port for each accepted connection all the time. Here is a taste of some of them: [Read More]

Javascript Does Not Need a StringBuilder

Today I learned that Javascript does not need a StringBuilder for accumulating a large number of concatinations. As a Java programmer, that came as a shock to me. This article summarizes my exploration of this fact. [Read More]

Deadlock: Who Owns the Lock?

What I Learned Locking a readlock, then locking the write lock on the same lock creates a deadlock. Deadlocks created using locks instead of monitors does not appear in thread dumps (like those created by kill -3 (linux) or Ctrl+Break (windows)). Keep digging and you’ll uncover a nasty incorrect assumption... [Read More]

Unit Testing Common Requirements

Suppose you wanted to unit test java.util.Map. How would you verify each implementation? Take a quick look at the Map javadoc, and you’ll find 20 implementing classes. Each Map implementation has common unit tests for requirements that you want to avoid copying. In this post I illustrate two techniques you... [Read More]

Dining Philosophers Problem

The book I’m going through, Programming Interviews Exposed, presents the Dining Philosophers Problem and their solution to the problem. Firstly, their explanation for their solution is weak because they do not describe the underlying principle they applied to prevent deadlocks. Secondly, their implementation of their solution still results in starvation.... [Read More]

How To Avoid Busy Waiting

Update 2021-04-08: Viliam, a reader on my wordpress spotted an error. Thank you again! I called notify() and wait() on the implicit this rather than the lock! This adds to my argument that the best way to wait for something is to use a Future. There are so many ways... [Read More]

Removing Characters From a String

Programming Interviews Exposed asks us to remove characters from an input string, looking for the characters in a second string. I am unhappy with solution they provide, particularly because of the reasons they use to invalidate what I believe to the better solution. You can check out my solution to... [Read More]

Preparing For Interviews

I have completed my Master’s Thesis and all that’s left is paper work. As a result, it’s time to prepare for interviews. I’m going through ‘Programming Interviews Exposed’ as practice. You can follow my progress at my github repository. Wish me luck in the interview process! I will occasionally make... [Read More]

Reading Books and Technical Papers on the Kindle (Method 2)

I’m trying to read a book similar to Elements of Statistical Learning (aside: the book is freely available by one of the authors, Professor Rob Tibshirani, here ) on my Kindle, but the method I outlined in my previous post does not work that well. Moreover, look at all the... [Read More]

Reading Technical Papers on the Kindle

Introduction I have a Kindle with a 6’’ screen and reading technical papers is difficult. However, I am fortunate that most of the papers I read follow the 2-column format. As a result, there is a technique available to make reading technical papers less painful. I have only tested this... [Read More]

An Eclipse and Hadoop Pitfall

For one of my course projects I inherited a project that was implementing a dimensionality reduction technique in map reduce. The previous owner of the project exclusively ran it using eclipse and used Mahout in Action’s examples as a starting point. The Problem I Inherited The following pattern was littered... [Read More]

Showing Mathematically That More Complexity Increases Test Error

People who understand machine learning know from experience that having to complex a model causes poor performance when you apply your models to the real world because it does not generalize. However, where does the mathematical intuition for this come from? Up until I saw today’s lecture, I only had... [Read More]

Beginning First Term of Master's Degree

My research focus is Databases and Distributed Systems. My thesis is still undecided. One thing I have figure out though are my courses. CS848: Large Scale Data Management Firstly, I’m taking CS848: Large Scale Data Management and it fits well in my interest of Distributed Systems and Database. As part... [Read More]

High Fructose Corn Syrup vs. Refined Cane Sugar Coca Cola

Motivation Recently my roommate and I got into an argument over being able to taste the difference between high fructose and cane sugar Cola. I hypothesized that you could taste the difference between the two because of the level of fructose. My roommate disagreed and claimed that fructose would taste... [Read More]

Unintuitive Scoping and Javascript Closures

I had this problem at work, and have simplified it and removed all context related to the project so this article can be easily consumed. The problem arises when you try to create a closure onto a local variable initialized in a for loop. [Read More]

Setting URL using Javascript

Severin just pointed out a much easier way to update the URL using javascript: <script language='javascript' type='text/javascript'> window.location.href = '/main/some_controller/some_action#some_anchor'; </script> [Read More]

Rails, AJAX, Back Buttons, and Bookmarks

Markus’s submission page uses AJAX to grab the next or previous page of the table of submissions. However, this breaks bookmarks and the back button. So the goal is to do something similar to gmail. They update everything after the anchor (#) in the URL. Here is what we can... [Read More]

Updating URLs with a href

You can put parameters into the URL with javascript. Here is an example html document: <html> <body> <a href='#test=test'>testing</a> </body> </html> [Read More]

Weird Behaviour Of Mocha

In the markus code, there are a lot of places where we use markus_config_<something> instead of MarkusConfigurator.markus_config_<something>. We should start using the latter. He’s why: [Read More]

Mocking Modules with Mocha

I could not find any examples on mocking modules with mocha. It’s probably because it’s so easy! It’s just like mocking an instance of a class. [Read More]

Nested Contexts

I learned a new trick with shoulda. Credit goes to: http://www.viget.com/extend/reusing-contexts-in-shoulda-with-context-macros/ [Read More]

Ruby, Permissions and Directories

I recently learned that if you remove the execute bit on a directory and try to rm -r the parent directory then you will be unable to remove the executable directory. However, this works in a terminal. [Read More]