Boston Gameloop 2010 #bgl10

I will be heading off to the Boston Gameloop 2010 conference at the Microsoft NERD center in Cambridge, MA tomorrow night. I decided to travel by the means of the Bolt Bus which provides both power outlets for laptops as well as free Internet for the trip. I am not quite sure the quality of either, but I expect to at least be online occasionally tomorrow night to chat on and off. I think I am going to take this time to work more on my Ruby on Rails project, Type Aloud, which I am hoping to launch sometime around the beginning of October. I will be sending around some beta invites when the site is ready to rock and roll.

Posted in Pennies for Thought
Tagged , , ,
C++ Generic Lazy Loader Implementation

Lazy loading is a software design pattern that delays the initialization of resources until the first time they are to be used inside of an application. Thus, for certain applications that rarely use memory intensive resources, you only need to initialize when there is a guarantee it is to be used. This has obvious performance and efficiency benefits. As a C++ programmer by trade I find it rather irritating that there is not a generic class that automatically handles lazy loading for me. So like any good lazy fuck I decided to spend a few hours and write one of my own. I currently have two use cases for this little tidbit.

When you have available a default construct its use is quite simple and straight forward. This object allocates the class with the default constructor when it is first called directly through any of the accessor operators, or directly with the get method. In this particular example when loaded it correctly returns the unique identifier.

class Unique
{
public:
    Unique() 
        : m_uuid(boost::uuids::random_generator()())
    {
    }
 
    const boost::uuids::uuid& uuid()
    {
        return m_uuid;
    }
private:
    boost::uuids::uuid m_uuid;
};
 
int main(int argc, char* argv[])
{
    thunk::lazy_loader<Unique> loader;
 
    const boost::uuids::uuid& u = loader->uuid();
 
    std::cout<<"uuid: "<<boost::lexical_cast<std::string>(u)<<std::endl;    
 
    return 0;
}

The second example uses a boost function structure as a factory method, and it is executed instead of the default constructor. The factory method takes a reference to a boost shared pointer and correctly calls the constructor with any obligatory parameters. The boost shared pointer is owned by the lazy loader implementation and is used to maintain a reference counted state.

 
class Unique
{
public:
    Unique() 
        : m_uuid(boost::uuids::random_generator()())
    {
    }
 
    Unique(const boost::uuids::uuid& u)
        : m_uuid(u)
    {
    }
 
    const boost::uuids::uuid& uuid()
    {
        return m_uuid;
    }
private:
    boost::uuids::uuid m_uuid;
};
 
static void factory(boost::shared_ptr<Unique>& impl)
{
    impl = boost::shared_ptr<Unique>(
        new Unique(boost::uuids::nil_uuid()) );
}
 
int main(int argc, char* argv[])
{
    thunk::lazy_loader<Unique> loader(&factory);
 
    const boost::uuids::uuid& u = loader->uuid();
 
    std::cout<<"uuid: "<<boost::lexical_cast<std::string>(u)<<std::endl;    
 
    return 0;
}

I am still working on a better method for initializing with a n-argument constructor. I have made my current progress available on my Github.com repository available for use with the standard three-clause BSD license. If you have any questions or bugfixes please feel free to submit them through Github.

Posted in Programming
Tagged , , ,
Digg 4 Alpha

The guys over at Digg have been gracious enough to invite me as one of the first people to use the new Digg 4 alpha. Let me say, the design and speed of the new Digg is simply amazing. It really shows how awesome a Cassandra backend can be. I’m glad to be choosing a NoSQL option for my upcoming project.

Also, in order to add this feed I need to post this bad boy up – db998ce11c694408adff259cf458c5c4 – have a good holiday!

Posted in Internet
Tagged
Getting A Job As A Programmer

My buddy, and fellow NJIT graduate, noble prize laureat, open source developer, Kenny Katzgrau wrote up a great post on How To Get A Job As A Programmer.

Anyone that may be interested in computer science as a major in college (or if you are already sitting in classes) that thinks they want to be a programmer may want to go read his little tidbit. If you’re in college to become a programmer I am personally of the opinion that you’ve already missed your calling. Switch majors immediately. You should love this craft before you decide to make it a career.

Posted in Programming
Tagged ,
Bouncing A Database With Rails

After work each night for the past couple of months I have been getting my hands dirty with Ruby/Rails development. I can imagine that most developers out there grow to love rake, but for the life of me I literally hate executing a series of commands on a regular basis. The programmer in me loves automation, and while in development I find myself dropping, re-creating and migrating the database constantly. Why should I have to issue three commands?

rake db:drop
rake db:create
rake db:migrate

After a little bit of searching I found that this can be accomplished in two commands.

rake db:reset
rake db:migrate

Welp, that’s not enough for me because I am just that damn lazy. So, a simple rake task to bounce a database.

namespace :db do
  desc "Drop, create and migrate the current database"
  task :bounce => :environment do
    Rake::Task['db:reset'].invoke
    Rake::Task['db:migrate'].invoke
  end
end

I hope you enjoy it as much as I do.

rake db:bounce
Posted in Programming
Tagged , , ,
iPad, iAd and No Bandwidth

Unless you’ve been under the rock for the past couple of weeks, by now you should have heard about AT&T killing the unlimited data plans for both the iPhone and iPad, then grandfathering in the iPad plans for people who buy theirs before the deadline and finally caving in and allowing a 30 day “grace” window until the deadline. If have been following that news then you most certainly have heard about the release of the iPhone 4.0 on the AT&T network and Apple’s change of tune on mobile advertising as soon as they decide to start their own ad network built in natively into the operating system. The big news obviously is the caps on data, 200MB and 2GB respectively, and how many people are rather irritated because the iPhone is built around connectivity. There has been continuous coverage on podcasts and blogs regarding how the 200MB plan is essentially crap and the 2GB plan is a necessity, but what people are not talking about is Apple is now going to be delivering advertisements to your iPhones and iPads which are going to consume quite a bit of bandwidth that you will now be paying quite a pretty penny for.

Of course one could argue that mobile advertisements have always been on the applications that are available through the App Store, but Apple themselves are toting these media rich advertisements that allow for running video, interactive games and streaming audio which out of all the possible digital mediums consume the most bandwidth. So not only are we now going to have advertisements pushed upon us, but the cheaper bill that AT&T is waving around in our faces will most likely be non-existant if these iAds push us over our bandwidth limit.

Of course Apple neglected to mention this little tidbit in their press conference earlier this week. Even though I am eligible for an upgrade on my account I think I am going to wait to see what happens with this whole bandwidth fiasco that AT&T is pulling, and more off, hoping that Verizon will get an iPhone this time next year coupled with an unlimited data plan that I can actually use in the New York City metro area. Here’s to dreams.

Posted in Apple, Internet, Technology
Tagged , , , ,
Finding Time To Write #iamwriter

At certain points in my life I tend to take long breaks from writing as it generally takes a good deal of time for me to get into the mood to pen something, anything, after a long day of work. I understand how you feel: the whole week seems to be filled with work; after your day job maybe you volunteer, go to classes or even have siblings or children to take care of. These responsibilities, even if minor, add up during the course of the week and you are left with, at best, mere hours a week to dedicate to hobbies. What I find unfortunate is serious writing takes effort. You must be in a creative state of mind, relaxed and focused all at the same time. For some of us this zen-like state is nearly impossible to get to late at night when all you want to do is go to sleep an hour early.

I have personally solved this problem in two steps. The first step is to always carry around something to write with. For me most of my creative ideas come when I least expect it. I may be zoning out on the train ride into the city, listening to a friend ramble on about their day during lunch, or even waking up in the middle of the night with a brilliant idea for a chapter or short story. The point is to always be able to jot these ideas down when they are fresh on your mind, in their most lucid form, because attempting to recall them later will be much harder than you may think! I suggest a cheap pocket-sized moleskin notebook that is available from Amazon or your local Barnes and Nobles store for under ten dollars. These notebooks tend to last being jostled around inside a jacket pocket, purse or sat on when in the back of your pants pocket.

The second suggestion I could give is to make a rule about writing. Every Wednesday, for example, add an appointment or notification on your phone to remind you to sit down and write for two hours. Be sure to add a reminder two hours before your writing period so that you can finish dinner, reading or studying. A notebook (or more likely, a computer) should be close at hand on this particular day, so be sure to choose a day when you are for sure most likely to be home from your other engagements.

A half hour before you are to write make sure you get yourself in the mood. Put in some relaxing music, distance yourself from any distractions like other people, television or instant messenger applications, and the most important piece to the equation – review the notes that you have been taking in your handy-dandy notebook. If they are related to a story that you are already working on be sure to refresh yourself with the previous couple of pages that you have written. Don’t get hung up on any spelling or grammar mistakes that you may have made, this is not the time to edit, but focus on the structure and layout of the story. A good editor will always go through your piece with a fine-toothed comb.

Remember that the most important thing is to enjoy what you are writing. Even though it helps to make writing a timed event, do not turn it into a chore, because it will that much harder to sit down at your computer desk and type away for hours. Get lost in what you are working on and enjoy the world that you are crafting. If you feel yourself getting bored with the story, do not be afraid to work on another chapter or entirely different story. Sometimes it helps to come back to a piece later to refine it.

Posted in Writing
Tagged , , , ,