• Merge Sorted Arrays Algorithm

    Posted on Apr 19, 2017

    The following is a simple algorithm to merge two sorted arrays. Merging two sorted arrays is essentailly the same as a single round in merge sort. If you were implementing this in a real project, you would probably was to use templates so this could work with any type. I've restricted this to only unsigned ints to focus on the algorithm. #include <iostream> #include <cstdint> #include <vector> /// Merge two sorted arrays /// @param array1 The first sorted array to merge /// @param array2 The second sorted array to merge /// @return A new array containing the merged result std::vector<std::uin...

  • Integer to String Algorithm

    Posted on Apr 19, 2017

    The following is a simple example for now to convert an integer to a string (doesn't include error checking, sign detection, non-base 10). #include <cstdint> #include <iostream> #include <string> /// Reverses the characters in the string /// @param str The string to reverse (the original string is modified) /// @return The reversed string std::string reverse(std::string& str) { std::string::size_type half = str.size() / 2; std::string::size_type end = str.size() - 1; for (std::string::size_type i = 0; i < half; ++i) { char tmp = str[i]; str[i] = str[end - i]; str[end - i] =...

  • Setting up a October CMS environment with Vagrant and Heroku

    Posted in Web on Mar 20, 2017

    OctoberCMS is an intersting CMS platform build on Laravel. There is a great official tutorial on how to setup OctoberCMS with a Vagrant box using the quick install approach. That approach is great if you will use OctoberCMS's project management tools to update, install plugins, themes, etc. But if you want to do any custom work, including install a composer package, you are out of luck. The quick install doesn't include composer.json, so there is no way forward. Alternatively, you can setup OctoberCMS via command line, which will give you a standard PHP/composer project, but there is no tutori...

  • Page not found - HTC OneX Mass Storage on JellyBean

    Posted on Feb 26, 2017

    Oops. I've changed the focus of my blog and the page you visited doesn't exist anymore.

  • Page does not exist - Installing GCC on Mac

    Posted on Feb 23, 2017

    Opps. I think this page may have moved. Maybe you want Installing GCC on Mac.

  • Installing GCC on Mac

    Posted in Coding on Nov 20, 2015

    Suppose you want to use the latest and greatest version of GCC on the Mac because you want to use features in C++11 that are not yet available in XCode. There are probably a few ways to do this, but one way is via MacPorts which provides precompiled binaries for tons of packages. You can follow the following steps to install GCC 4.7 via MacPorts. Others versions (including GCC 4.8) follow a pretty similar procedure. Browse to the MacPorts website. Download the DMG image for your operating system Install the package Open up a terminal Applications > Utilities > Terminal Make sure that you hav...

  • Using Redis as Django Worker Queue on Heroku

    Posted in Coding on Nov 20, 2015

    Heroku documentation recommends using Redis Queue to setup worker tasks. But for me, that document was pretty incomplete for how to setup Redis Queue for a production Django application. This guide will show you how you can setup Redis Queue to schedule regular worker tasks for a Django application running on Heroku. What do I mean by "schedule regular worker tasks"? I mean run some code on a regular basis, for example every day email a report of users over the last day. Or, for example, every 12 hours automatically delete some cached data from your database. This guide is also useful if you w...

  • Development Process: From None to Not None

    Posted in Coding on Nov 07, 2015

    A pretty common question I'm asked is what kind of R&D process we used (and I implemented) at my last company. The question is enormous because it covers at least tracking bugs, handling feature requests, code branching strategy, testing and deployment. The answer is even more difficult to answer because our process evolved as we got better and responded to what was happening around us. I think the evolution is instructive because it represents real choices we faced. If this is a story, then it has to have a beginning. The story for me begins with the state of affairs when I joined. The initia...

  • Passing the YCombinator Interview With No Preparation

    Posted in Business on Oct 13, 2015

    For me, applying to and interviewing for YCombinator was a whirlwind experience. We applied a few days after the deadline and then didn't hear anything until 5 days before we were to be in California for the interview. Unlike anyone else I spoke to, we essentially did no preparation. Quite honestly, we were working on another major deadline that week, and simply didn't have more time to prepare. Still, we managed to get in, so we must have done something right. Although the title of this post is all about no preparation, I don't advocate that approach or any other. I don't have any advice, but...

  • Split Windows and Linux Configuration

    Posted in Coding on Sep 25, 2015

    This is part 4 of a 4 part series on how to setup Django locally on Windows and deploy to Heroku. Introduction Setup and Run Django+Heroku Locally on Windows Change Django from SQLite to PostgreSQL Split Configuration for Windows and Linux (this page) You may recall from the first page that setting up Django locally on Windows and deplying to Heroku has a problem. If the application uses PostgreSQL, then the configuration between Windows and Linux cannot be the same. This final part describes how to setup the configuration (requirements) so that Windows and Linux have different requirement...