Musings from an east coast software developer, writer and reader.

From the Blog

I have been doing some hacking on Type Aloud and I was looking for an answer to a question that was bugging me: what is the best way to use link_to with a vanity URL setup? I asked my question over at Stack Overflow and I figured I would post the answer to the question here in case anyone was looking as I was.

Inside of my application the route setup is quite simple.

match '/:id', :to => "users#show"
match '/:user_id/:id', :to => "stories#display"

Now I want to be able to make a very simple call inside of my view logic which will print out a pretty URL. Since I am using resource definitions for several controllers I cannot use the normal Rails URL helpers. The answer to my question is actually quite simple, and I already have used it before, but what I wasn’t doing was correctly passing through the objects into the helper. Here are the changes that you need to make to those routes above.

match '/:id', :to => "users#show", :as => "vanity_show_user"
match '/:user_id/:id', :to => "stories#display", :as => "vanity_show_users_story"

And finally inside of your view you would build both links like the following.

<%= link_to @story.name, vanity_show_users_story_path(@user, @story) %>
<%= link_to @user.name, vanity_show_user_path(@user) %>

I hope that this helped you out as much as it helped me! Kudos to the amazing Ryan Bigg for the original answer.

The past couple of weeks I have been doing some research because I am planning on working on a FastCGI Model-View-Controller framework for developing web application services in C++. I am a C++ engineer by day and have been working with the language for nigh on a decade. The brief research I was able to do has shown me that there are no DataMapper or Active Record open source libraries available.

What Exactly Is The N+1 Query Problem?

When using an abstract framework to build a data model for use with an SQL-esque language you generally need to build a set of classes to model the schema in said language. For Type Aloud, lets say that I want to display all of the stories in a set of categories after you get them back based upon two slugs taken from the site’s URL.

SELECT id FROM categories WHERE slug='sci-fi' OR slug='fantasy'
SELECT id, name FROM stories WHERE category_id = 0 OR category_id = 1

How many queries will be run? At most there will be two queries, but what about if none of the categories match the two slugs provided? That first dangling select query will be executed each and every time even if there are no matches to search against. How can we fix this?

SELECT * FROM stories 
INNER JOIN categories ON stories.category_id = categories.id 
AND (categories.slug = 'sci-fi' OR categories.slug = 'fantasy')

This type of explicit join will allow you to execute a single SQL query and, in the long run, will save you thousands of CPU cycles with your web applications. This type of data mapper already exists in Ruby on Rails using the Data Mapper gem which is freely available. But as of right now there is no such framework available (unless I am mistaken) in C++ which gives you the power and flexibility to build your data models and eat your cake too. My first plan in developing an MVC framework is to work on architecting a proper data mapper library for C++.

Anyone else game?

I decided to take some long needed rest away from the computer and enjoy my Thanksgiving holiday with friends and family. This has put some of my development initiatives on the back burner. I am aiming to gear up this weekend and hopefully be able to release a little tidbit at the end of this weekend just for the special someones who sign up for the service early. The current goal is to have story and chapter submission, viewing and commenting up by the end of this weekend.

I will continue the remaining work and slowly release the bits out to my testers. I expect (and hope) those of you that have signed up are ready and willing to start writing some short stories, and eventually, poems!

I have arrived at one of the bullet points for Type Aloud where I must implement the ability for one user to follow another user, similar to being a friend on Facebook or exactly the same as becoming a follower on Twitter. But I came to a dilemma that needed to be solved: What if someone only wanted to follow one particular story from an author?

The first thing that came to mind (and ultimately stuck) was to have two different type of subscription models – the first would allow you to physically subscribe to a story and be notified when a new chapter was posted by said author. This subscription would keep track of reading point on a particular chapter as well as what chapter was the last one that you read. This may seem very trivial for web browser users but when you plan on handling Amazon Kindle traffic this becomes very important. The second subscription model would be a “Fan” and this is where you want to hear absolutely everything from the author – if they decide to post a new story, you hear about it, or if they decide to write a poem, the same deal.

When thinking through this I was trying to take into consideration user interaction. How would the button placement work for these two particular types of subscriptions? If someone wanted to cease being notified from said author, how exactly would that work? And finally, if someone subscribes to another author’s story and then becomes a fan what happens if they eventually cease the fanship – do we maintain the original state of subscription?

I would be interested what you all have to think.

A decade ago most of America connected to the Internet through some form of copper telephone line, and America On-Line was the service to be on. I remember dialing into a local telephone switch because hours on the Internet could run you hundreds of dollars in long distance fees. Oh boy has the landscape changed. The slowest cellular network available is still much, much quicker than the 56K dial up that I grew up with.

My good friend Kenny Katzgrau has written a blog post about his thoughts about the social networking phenomenon and some questions that he has about new “boom.” Has the service that Mark Zuckerberg stole pioneered a new type, a new form, of real-time communication and interaction with the world?

These social services such was Twitter and Facebook both provide a new medium to communicate around the world. This instant, publish-anywhere, status update has much more power than merely giving your ex-girlfriends the ability to stalk you on their iPhone. In merely 140 characters millions of people convey joy, hatred, love and disgust for anything and everything. Our thoughts, what we might have once kept to ourselves, can now be broadcasted to millions of people who are drooling to read the next quip from Ashton Kutcher. Mere mortals have become super stars because of Twitter.

Is this much different than Yahoo Chat a decade ago? There were literally thousands of rooms available for all sorts of pleasures. This then, instant communication tool, was a first of its kind. Yahoo pioneered one of the first social network web site providing photo profiles, chat services and much more – five years before Facebook even existed. Why am I going on and on about history?

  1. How will Facebook and other social networks become even more real-time?

    I think that this answer is less about the technology and more about the ability to integrate, aggregate, information in a single package. A few years ago web portals such as Yahoo were shunned – we wanted the minimalistic design but the amazing power of Google’s search solution. We didn’t need a directory curated by Yahoo minions. But what is the most interesting morsel is that we are now looking to integrate services because it is a pain in the ass to deal with the replication of data and information.

    As human beings we do not want to have to continually type in the same information into different services. I want to be able to log into websites with my Facebook account, and update my status on Facebook via Twitter. Why do I use Twitter instead of Facebook? Market share? Hype? Twitter definitely does not have a technical advantage over Team Zuck.

    I believe that the future is aggregation. Facebook et al are going to integrate with each other. New data is going to be created because of this, and services will crop up to mine, analyze and display this information in new, interesting ways. Google realized early on that data and information is king.

  2. How will desktop software fit into the picture?

    All of the JavaScript engines will eventually fall into oblivion and the Internet browsers will go with it. We’re going to see less and less differences between browsers and more focus on integrated experiences with services. In the case that Kenny brought up, Rock Melt, a browser designed with social connectivity in mind, is a first step towards this. Google has introduced a plugin-based software extensions for its Chrome browser. We’ll be using more and more services over the air via web API endpoints and less of the actual service through their web sites. The new crop of Internet businesses will be “cloud computing” style service-oriented websites that sell access to their API and offer a limited front-end to an overly simplistic service.

  3. How many investors will spend money on social applications?

    What exactly isn’t a social application now on the Internet? Any new business will need to embrace the social aspect of the Internet or another business that does is going to crop up and displace them. Very few services are going to be able to get away with this.

  4. What is the sum of it all?

    As I said before this is leading to an Internet that is a jumble of inter-connected services that are all providing data, for a price, to any client that is able to access the public API. We’ll a lot of services that both combine two competitors’ data into an application that trumps the user experience of both. The future of the Internet is decentralized information, plain and simple.

I could go on and on for hours regarding this. If any of you have thoughts please feel free to comment here, or head on over to Kenny’s blog and make sure to use both of our URLs in your WordPress callbacks!

Nov
11

I have had a few people asking me the progress on Type Aloud, my brand-spanking-not-yet-released-but-still-new writing (and reading) community on the Internet. The past couple of weeks have been hectic regarding personal obligations, but I am still on track for having a beta release by the end of the month. Here is what you can expect for the totally awesome beta release (for those of you that sign up for early access):

  1. The ability to create stories (with chapters) and poems.
  2. Discussing stories and poems in an organized fashion with the rest of the community.
  3. The ability to become a fan of an author and get notified about what they are reading, writing and commenting on.
  4. Categorizing and searching stories and poems via genre specific tags, e.g. Fantasy and Sci-Fi.

I am about 70 percent finished with the initial release candidate (the above features are all included). I am hoping to hit a December 1st beta release date for early access and a January 1st beta release date for everyone else. I will be turning off early access sign ups during the initial beta period but will allow each user that has signed up to invite a select number of other users before the January 1st launch.
You can follow @typealoud on Twitter to receive the most up-to-date information as I write it. For the launch of the service we will be raffling off an Amazon Kindle, but there will be more information about that as the time grows near!

Nov
11

When I was in college we would inadvertently put ourselves into the situation where we would do this a lot; go to the classes during the day, spend some time with our friends and take a nap a little before (or after dinner). Later that night we would stay up until three in the morning either hanging out, writing code or playing video games. Of course at the time we did not know it was called a polyphasic sleep cycle but nevertheless it worked for us.

Earlier this year I joined the working stiffs of New York City and could no longer do this because it just became too much. But yesterday I came across several informational sites which showed some promise in doing this. So after some time calculation the plan is that next week I am going to begin trying this out.

Basically how this works is that as soon as you get home, let’s say around 7:30PM, you hit the sack and take a nap for about an hour and a half. At 9PM you should awake feeling quite refreshed and go on with your business until 2 or 2:30AM. At this point, at least for me, I plan on sleeping until roughly 7AM which will total approximately 6.5 hours of sleep per night. Most people average around the 8 hours per night mark which is a significant time sink when you extrapolate that across your life. Its quite absurd how much time we spend sleeping.

So, that’s the plan. I’ll keep this little “life hack” up-to-date as it progresses. From how it sounds I do not believe it will be much different than what I was doing in college (and in high school) which worked out nearly flawlessly. It may take a few days to get back into the groove of things.