This blog has moved to Medium

Subscribe via email


Posts tagged ‘Stackoverflow’

Add StackOverflow-specific search to Chrome for fun and profit!

When I saw Chrome’s Custom Search feature a while back, I didn’t think of any particular use for it for me.
However, lately I’ve noticed that a lot of my queries end in “site:stackoverflow.com”.

So, I went ahead and setup shortcuts for searching Stack Overflow (and Super User, while I’m at it). From now on, if I want to make the turtle move in Logo, I simply type “SO turtle logo” into my Chrome’s omnibox.

To set this up, see this link.

Who wants a Stack Overflow T-shirt?

Still in beta (not announced on the SO blog yet). A shirt is $12, shipping to Israel is $11 fixed price + $4 per shirt. Let me know if you want one and we can do a shipment together.

Stack Overflow shirts

My favorite Stacks

I blogged before about the StackExchange platform for questions and answers.

A few months have passed, and a whopping 218 different “stacks” emerged (there might be some more off the radar). While most of them are still ghost towns, a few are starting to be rather useful (some more and some less):

Regarding my own experience, I am nowhere close to breaking even. Until now, StackExchange has been a free (beta) platform. When it come out of beta, they will start charging $120/month. But, I’m optimistic, and I don’t mind funding Draw3Cards from my own money for the next year – it is picking up in terms of traffic. Meanwhile, I have also done a little bit of development of a similar open source, though I hadn’t perused it beyond a “programming exercise” yet.

P.S.

Needless to say, the original Trilogy – StackOverflow, SuperUser and ServerFault – continue to be an invaluble assent in programming, using a computer and IT. Rock on!

P.S.S.

I just found Shapado, a free, open source hosted version of Stack Exchange. They are taking a lot of heat from some of StackExchange’s users, but I think their existence can only be good news to StackExchange’s users. I probably won’t be switching Draw3Cards to Shapado any time soon because the platform is still not ready (less features, not as smooth), but time will tell.

An open source StackOverflow clone by a n00b web dev

Edit – just so you know, since writing this I found Shapado and OSQA, which seem well underway to becoming viable Stack Exchange alternative. I don’t think I will continue developing this project, although it has taught me a great deal nonetheless.

I wanted to share a small learning exercise I underwent recently. I decided to learn how to build a website, and share the experience here. Lacking an original idea at the moment, I decided to create yet another StackOverflow clone – not original, but a good exercise nonetheless. The code for the project is hosted at GitHub, although I don’t have a live showcase up at the moment. Yes, I am aware a google search reveals an existing open source SO clone called Stacked – I thought building one from scratch might teach me more than reading someone else’s code base (I could be wrong, but this is how I wanted to roll).

Day 1

The choice of database engine was easy: The one database I had any experience with was mysql, and being open source, free and easy to work with, I went with it. Next, an ORM library. After some digging, I’ve decided to go with NHibernate + Castle ActiveRecord. ActiveRecord is great for easily mapping simple classes and relations, and NHibernate to complement it in ‘advanced queries’. I don’t get any LINQ magic from these ORMs, which is a pity. I then proceeded to create a solution and some projects, added NUnit as a test framework, and setup Castle MicroKernel as an IOC framework.

I tried to found an open hosted source CI server, but didn’t find anything that worked. Oh well, not essential for now.

Day 2

Before proceeding any further, I had to choose a source control provider. If this were a production project I would probably have gone with SVN hosted on Google Code. However, Ken told me about Git long ago, and I thought this was a good chance to experience it. So, on to GitHub. Opening the project was a no brainer, but finding a decent client was more challenging. I had some fun learning about Git’s private keys, and configuring TortoiseGit (I tried GitExtensions, but it doesn’t support Visual Studio 2010 beta 2 yet). Overall, TortoiseGit gets the job done, after some tweaking and .gitignore files.

Git’s distributed source control model is interesting and worth a try.

I created the User, Question & Vote tables, learned about composite keys in AR, and wrote my first NH query:

GetVoteCount – “SELECT Vote, COUNT(*) FROM ” + VotesTableName + ” WHERE PostId = :postId GROUP BY vote”

I currently don’t have any caching on the vote count – am simply storing the votes as relations between users and questions, and counting them on the fly.

Day 3

I would like to implement full features, not write the entire DAL first and then the application logic. So, it’s time to start learning about web development. At work people are using Monorail, but after reading this question I decided to try out ASP.Net MVC instead. So, I read a basic tutorial and starting coding. Some things I learned:

  1. I finally got the meaning of Global.asax.cs – it’s simply the ‘main’ of the web application.
  2. By default, ASP.Net MVC creates the controllers by itself and does not support IOC. Fixed (remember to setup the Controller’s lifestyle as LifeStyle.PerWebRequest).
  3. Some Asp.Net MVC basics:
    1. Use <%= … %> to write to the output stream (that gets sent as the HTML), and <% %> to simply execute code.
    2. Use Html.RenderAction() to create links to other pages (~= Actions)
    3. Your pages are butt ugly without tweaking the CSS

Day 4

  • I quickly caught myself duplicating code, and turned to learn about Partial Views, which are reusable View pieces.
  • I realized that having my model entities derive from ActiveRecordBase is damn ugly, because it makes my entire application dependant on AR even if I was using repositories to access the data. I switched the repositories to using ActiveRecordMediator instead.
  • The magic that is ReturnUrl – an extra request parameter that controllers use to return you to your original page after you login.
  • An interesting usage for anonymous object creation syntax in C#, to pass query parameters: new { ReturnUrl = “foo”}
  • I decide to create a base class for all my controllers – UserAwareController. This was needed because every controller needs to access the current user, so I put all this logic in the UserAwareController base class.
  • Since every View needs the User to render, I created a Model base class that contains the current user. I’m not sure if this is the best way to go here, but it worked (what are your recommended best practices to store the user data?)
  • I implemented OpenID login using DotNetOpenAuth, and it was quite a breeze. No need to store user credentials, just store his public open id and let other websites handle the authentication for you.

Day 5

After allowing users to login and post questions, the next thing I wanted to implement was voting. So far all the code was server-side, but voting requires javascript because when a user votes you don’t want to refresh the page, but rather just change the vote icon. So:

  • I learned about jquery basics and wrote events to handle clicking the voting buttons.
  • Sent the vote information to a dedicated controller using JSON. The way JSON requests translate to controller methods is really seamless.
  • Initially I had an ‘AddVote’ method, but quickly switched to ‘UpdateVote’, which makes more sense.
  • Some css tweaks to make the cursor change to a pointer while on the voting buttons

Day 6

  • I finally had to cache vote count on questions & answers. The total vote count / score of a question has to be indexed, because we’ll have pages that get the ‘hottest posts’, and so keeping the User-Question vote relation is not enough.
  • So far, all my entities were strictly mapped to database rows. Now, I had to create a new ‘rich entity’ that contained a post and the current users’ vote on this post.
  • Finding myself duplicating logic between questions & answers, I create a Post base class and factored the entities and repositories to work on abstract posts.

This is it for now. I hope I didn’t make too many glaring mistakes in the process. As I mentioned, the code is available at GitHub – if you’re interested in helping develop it or have any questions, please let me know.

There’s a (meta) community emerging

As you probably know, I joined the new wave and got my own Stack Exchange site. It’s really amazing how many different SE sites are emerging so rapidly. There’s a strong sense of (meta) community with most of the site owners heavily participating in discussions on meta stackexchange.

There is some overlap between different sites, but most sites I’ve seen are original and useful. The owner/s of one SE site have been nice enough to post links to other SE sites, including Draw3Cards, at the top of their homepage!

Today I convinced a friend at work to open his own website, and I think you should to – before all the good ones are taken. Come and join us, it’s really that easy.

Trying out the StackExchange platform

For the last couple of days I’ve been obsessing over a new toy. Jeol & Jeff, the powers behind StackOverflow, have launched a public beta of StackExchange – a platform for hosting Q&A sites. Browsing the list of stack exchange sites, I saw several more and less successful sites, including:

I decided to try and open my own site, about Magic: The Gathering. The setup itself was rather easy. I:

  • Bought a domain and set it up, with some help
  • Seeded the site with some questions and answers
  • Tweaked the color scheme, logo and favicon (thanks Eran)
  • Got some friends to help out (though so far they’ve only posted answers, not questions)
  • Setup Google Analytics, and noticed incoming search traffic only stayed for 42 seconds on the site
  • Opened a small AdWords campaign, paying 1.5$ a day to test the water.
  • Post the site on this blog, of course.

Now what remains to be seen is whether the site can accumulate the needed critical mass. For now, the site is in beta, meaning I don’t have to pay anything to keep it running (except time and effort). When the beta is over, the cost will be $129 a month, which is quite challenging to make using adsense.

Keep your fingers crossed for me 🙂

P.S.

Just got a $100 coupon for AdWords by visiting Google Webmasters Tools – how cool is that? In a second look, it appears the coupon was lying in my Webmasters Tools inbox for two months now, just waiting for the perfect opportunity.

I also forgot to mention opening a uservoice forum (+ adding the widget to my site).

So this is what an empty StackOverflow looks like

Well, I said this would happen.

StackOverflow’s flood gates are open, and there are many new sites based on the stackoverflow engine.

One of those that I think has great potential is Ask Science, though at the moment it’s rather desolate:
asksci

StackOverflow Overflow

StackOverflow is branching out heavily in the past months. First, SystemFault, a sysadmin-targeted site. Then, they purchased SuperUser.com (coming soon) – a site for home users (questions like ‘how to configure my router’).

And now, a meta discussion forum. It seems the process of cloning or ‘flavoring’ SO is now almost streamlined. I wonder how many stack overflows will we have a year from now. In two years? I think it’s rather unfair that only us programmers (and now sysadmins) have such a great resource. What do you think – will SO clone into Q&A forums for other non-computer topics (a suggested name for a law-based SO – ObjectionDenied :))

P.S.

Apparently,  there’s already a  release date for the platform! Prepare for the onsalught of StackOverflows.