Clouds screenshot

This article is part 1 in a series of articles about an “open source project” I’ve been working on. I’ve put it in quotes because it’s not a real open source project in the sense that many people has worked together – it’s a hobby project with me as the only developer, and now I’m choosing to make its source public because I feel like contributing something back to the community. I call this project Clouds, and you can try it right now, right here.

The idea behind Clouds
Basically, Clouds is some kind of generic notice board. I wrote Clouds because I wanted to use it make a wish list application with a different approach, but I also wanted to make it generic enough to be able to reuse it in other applications. Perhaps even transform it into an engine to make it easier for other people to use it in their applications.

Upon entering the Clouds for the first time, a blank cloud is created automatically. The user is presented to an entirely white page (except for discreet menu bar at the top) and are able to add topics anywhere on the page by double-clicking and entering a text in the appearing box. The user can also add notes to topics, move topics around and even delete them again.

To further enhance the users ability to express themselves freely in their clouds, one could add features such as choosing the color, size and font of topics, but that is not essential to the real function of the cloud: To let users build lists in two dimensions instead of just one (typically vertical). In its bare form, Clouds can be used in many ways and taken in many directions, which is why I wanted people to be able to extend the application to suit specific needs, like a wish list, a mind map or …

As I had this basic functionality, I felt Clouds needed a bit more functionality to be usable to anyone, and yet I still wanted it to be basic and generic. So added the ability to protect editing and/or viewing with a password (not a registration and login – too much work for the user), and the ability to extend any list into a new list. The extension feature would be vital in, say, the wish list application, because it would allow people to extend a wish list and then coordinate who is buying which presents through their new list without the gift receiver knowing, while still maintaining the link to the original wish list.

I still have several ideas for things I want to add or improve, i.e. something as basic as getting the whole thing to work properly in Internet Explorer (no, Prototype and Scriptacolous cannot save you from all the headaches of IE), but also the fancy notion of synchronizing lists live between users, so multiple users working on the same cloud will see each others changes immediately.

The rest of this article and the one(s) to follow will dip into the technical aspects of Clouds, especially highlighting the parts where I’ve run into trouble. You can review and download the source code right here, but remember to check the license if you want to reuse any substantial parts of the code.

Creating a RESTful Rails application
What does it mean for a Rails application to be RESTful? To me it means to use the scaffold_resource as a basis for most entities in the application, and to strive to keep the application normalized by having only the CRUD actions generated by scaffold_resource in the controllers. Of course, these actions will also give the application a RESTful web service API for free, but that’s just an added bonus to me.

This article is a not a tutorial, but I do want to walk you through creating a RESTful Rails application as it will help you to build cleaner applications, also when it comes to database structure. To build Clouds, my first task was to generate the two central entities: The Cloud and the Topic.

./script/generate scaffold_resource Cloud title:string, created_on:datetime, updated_on:datetime, password:string, settings:integer, parent_id:integer
./script/generate scaffold_resource Topic cloud_id:integer, text:string, notes:text, posx:integer, posy:integer

The scaffold_resource generates everything you need to get started with your new entity: Model, controller, views, migration, tests and route. No need to worry about when to use singular or plural names, lowercase or uppercase, underscores or camel case. All files are created and named according to current Rails conventions. All you need to do is run rake db:migrate and restart the server.

Take a look at config/routes.rb. The generator has added map.resources :topics and map.resources :clouds. This enables the user to browse your Rails application using the nice RESTful urls, meaning that the same urls are reused for different actions, depending on the HTTP method used. For instance, if you do a GET (opening the page in your browser) on the url /clouds/1 the controllers show action is invoked, while a PUT on the same url will invoke the update action.

As you can probably read out of the scaffold_resource statements, a Cloud has a title, a password, some settings and a parent (plus two timestamps automatically updated by Rails), but for the basic functionality of Clouds, none of these attributes are required. A Cloud is nothing but a collection of Topics, and a topic has a text (short “headline” visible at all time), notes (longer text only visible on mouse over) and a position on the screen.

Take a look at the index action in the clouds_controller. After determining if the user already has a cloud to edit (by reading a cookie), the action utilizes either the edit_cloud_path(cloud) or the new_cloud_path methods to redirect the user. There is nothing new about named routes in Rails, but as a part of using RESTful Rails we get these named routes for free. Another interesting point in the clouds_controller is the calls to an authorize method located in application_controller, which is used to check if the user is required to enter a password to either view or edit the cloud. This method is invoked with a symbol as its third parameter, which is used to ask the cloud if either the show or edit action are protected (cloud.send(method)). I think that’s quite clever use of Ruby’s fantastic reflection abilities.

Using bitflags
A last thing I want to highlight in this first part in my article series about Clouds, is my use of bitflags. I believe the term bitflags is used and understood differently by different people, but in this context I talk about storing multiple true/false values in a single integer. In Clouds I needed to store some settings per cloud, specifically if the cloud’s show or edit actions where password protected. I could have added two fields to the clouds table called protect_edit and protect_show with the data type boolean (bit), but what if I needed further settings later on? Should I just continue adding more fields to my clouds table?

No. I believe bitflags is a cleaner solution for this, and to my enjoyment I was quickly able to find a small plugin providing me with this exact functionality called has_flags. In a nutshell, bitflags uses the power of 2 to combine multiple numbers into a single integer, while still being able to tell exactly which power of 2’s are in the integer. So the bitflag 22 are the numbers 2, 4 and 16 combined, while 8 is not present in that bitflag.

Take a look at the cloud model:

# Utilizes the has_flags plugin for easy bitflag usage
has_flags [ :protect_edit, :protect_show ], [ :column => 'settings' ]

This single line of code automagically adds protect_edit and protect_show as boolean attributes on the cloud model, while [ :column => 'settings' ] tells the plugin to store the bitflags in a field called settings. This is an easy, elegant and first and foremost “Railsy” way of using bitflags in your models.

In part 2 of this article series on Clouds we jump into the core part of the application: The javascript.

Bookmark and Share
  • Comments Off

How Ruby on Rails has made me a better programmer

28 Jan 2007 In: rails

With this article I am taking up the challenge in Pat Eyler’s blog On Ruby, which is: Write a blog about how Ruby on Rails has made you a better programmer.

I saw the light in January 2006. Yes, it was that late. Up until then, I’d been a Microsoft-programmer all the way. ASP taught me to do server-generated homepages. C# taught me to do object-oriented programming. But Ruby on Rails taught me that programming was an art, and not just a craft.

A friend I met in college introduced me to the open source world back in 2003. He tried to convince me that Linux and Perl was much better than my beloved Microsoft equivalents, and while I didn’t buy into that back then, it did widen my horizon quite a bit. Another good friend told me about Ruby on Rails when it was first made public. “I haven’t tried it myself, but it’s supposed to be really cool, and the guy who created it lives in your neighborhood.” I wasn’t convinced, but the notion of this cool, new way of developing web applications stuck with me, nevertheless.

I saw the light in January 2006. And by light, I’m not just talking about Ruby on Rails, but that whole new paradigm Rails is part of. Some like to call that paradigm web 2.0. For me, web 2.0 is more than just technology; it’s more than Rails and Django, blogs and podcasts. It’s about being open, giving and sharing stuff. It’s about really smart people not just trying to earn a lot of money, but also having a genuine desire to help other people getting better.

Ruby on Rails has made me a better programmer by showing me how easy, friendly, open and helpful things should be. Compare the Rails community to the ASP.NET community. The ASP.NET community is certainly not without people willing to share and help out, just look at Codeproject, but I have to say that I think the average Rails-programmer’s IQ is higher than that of the average C#-programmer’s. This is probably because the Rails community is smaller and attracts certain kinds of people, but I wonder if it will be watered down as it grows, or if we can continue to be nice and helpful to each other.

I had several fantastic experiences with Rails during the past year. RailsConf was awesome, not only because it had so many great speakers, but especially because everyone was so damn nice! Also Copenhagen Ruby Brigade was formed, and we were lucky enough to get the company of David Heinemeier Hansson and David Black to one of our sessions hosted at my workplace, Kraftvaerk.

So how has Rails made me a better programmer, technically speaking? Well, I can’t say the stuff about DRY and testing and DSL’s and so on was new to me when I started doing Rails – I mean; I’ve had The Pragmatic Programmer in my book shelf for years – but there are things about Rails that make it easier to do things right, and harder to do them wrong. I’m quite interested in some of the more … academic sides of Rails, like how it utilizes patterns, and an important example of that is the whole RESTful notion, which is “new” in Rails 1.2, but has been used by me and many others since it was in EDGE sometime last summer.

For me, it boils to this: More models with fewer actions. Preferably only the CRUD actions, index, create, update and delete. Why is this good? Because it’s convention. Example: Instead of /users/login you have /sessions/new/. It makes sense to me, and like many other things in Rails, it tells me do more of these conventions, also in my ASP.NET applications.

Has Rails made me a more productive programmer? Well … yes and no. I mean, the Rails framework is much more efficient and intuitive to work with than, say, the .NET framework, and Ruby does have a lot of clever ways of doing things in one line that requires 5 or 10 ten lines of C#. But … I also spend a lot of time browsing and searching the Rails API because I can’t remember the order of the arguments to call select. If I had intellisense like I have in Visual Studio 2005, I’d just start typing. I also find my Rails applications much harder to debug and install (deployment through Capistrano is a dream, but Apache, Lighttpd or even IIS to run the code is different!) than my ASP.NET applications. Okay, things are getting better and easier, but my point is; it’s not all good.

Nevertheless, Ruby on Rails has widened my horizon and opened my eyes, and that’s worth more than any productivity boost.

Bookmark and Share

Your own Mac OS XP with Parallels

7 Jan 2007 In: mac

Mac OS XP

Simple question: Am I running Mac OS X or Windows XP in the screenshot above? (Click to enlarge).

Simple answer: I’m running both.

Complicated answer
I’m really running Parallels with the coherence feature enabled. Parallels is an application that utilizes the Intel processors in newer Macs, allowing Windows XP to run in a virtual machine, but without the whole hassle of emulation. Without emulation, speed is greatly increased.

Coherence means that the Parallels makes the Windows desktop transparent while running the virtual machine full screen. This allows Mac and Windows applications to run side by side, without the hassle of having to switch to the virtual machine, and then selecting the Windows application you want to use. This way; Windows application really feel like any other applications on Mac.

This is cool, but it’s old news. Now, I’m using boot camp to dual-boot on my Macbook Pro. I use Windows for .NET development at work and for gaming. I use Mac OS X for everyting else. The great thing about this new beta of Parallels I’m running, is that I don’t have to create a new virtual machine and install Windows, Office, Visual Studio and so on. I can just boot my existing Windows partition directly in Parallels. How cool is that?
If you are dual-booting between OS X and Windows, I can only recommend that you try out the free 30 day trial of Parallels. It is unbelievably easy to get up and running; you just go through a wizard, select Boot Camp, and – BAM! – you have your well known Windows desktop right there next to your Dock, Mail, Safari, and so on. If you try this setup, I have one tip for you: Don’t attempt to click on anything when you boot in Parallels and Windows detects new hardware. Parallels will take care of everything, so just sit back and wait until the virtual machine is not working anymore.

And by the way: Running your Windows partition in Parallels doesn’t in any way change or harm the partition. You can always boot into Windows as usual, which is still necessary if you want to play a 3D game.

Bookmark and Share
  • Comments Off

Need a web developer?

Hello, I'm Casper Fabricius. I have developed for the web for 9 years, and have been enjoying Ruby on Rails for the past 4.

My experience covers communities, shopping solutions, multi-language sites, heavy back-end lifting and a wide selection of more traditional websites. I like to integrate Ruby with Java and .NET through JRuby and IronRuby when it makes sense. I am passionate about test- and behavior-driven development, but at the same time I am pragmatic and believe in getting things done.

I am based in Copenhagen, Denmark, but I take assignments from across the globe. Feel free to study my resumé, featured projects and - of course - to hire me.

buy paxil canada
buy viagra without a prescription
cheap levitra online
cheap discount soma
buy viagra pharmacy online
cheap discount levitra online
premarin
buy viagra now online
buy legal fda approved viagra
cheaper viagra levitra cyalis
buy medved viagra
discount viagra brand drug
discount viagra in the usa
buy viagra softtabs
buy viagra on line
buy cheap generic viagra
buy online viagra securely
buy viagra next day delivery
cheap online pill viagra
buy lasix
viagra canada prescription
viagra and cialis and
buy discount zoloft
cheap crestor online
buy buy cheap viagra
cheapest price for viagra
cheap pill viagra
buy sildenafil viagra
buy in online uk viagra
cheap cialis viagra
cheap drug retin viagra wellbutrin
order viagra licensed pharmacies online
buy viagra from brazil
cheapsest viagra online
cheap order prescription viagra
buy form generic viagra
buy viagra at safeway
cheap deal discount viagra viagra
cheapest viagra online in the uk
cheapest viagra uk
buy hgh now
buy crestor now
buy viagra in the philippines
buy generic online viagra
cheapest online viagra
order forms for buying viagra
cheapest generic silagra viagra
buy caverta
buy cheap cialis
buy now online viagra
buy cialis canada
buy viagra online 350
order prescription viagra
discount viagra sale
buy viagra from an online pharmacy
order generic viagra
cheap cheap viagra
cheap cheap herbal viagra viagra viagra
viagra by mail order
buy viagra low cost
order viagra usa
cialis 32
buy cheap soma
buy viagra cialis
cheapest viagra in uk cheap
buy online online pill viagra viagra
buy internet viagra
cheap online pharmacy viagra viagra
buy cheap discount levitra
cheap online purchase viagra
buy viagra onlines
buy real viagra pharmacy online
cheapest cialis
buy viagra and cilas usa
buy viagra online order
over the counter viagra in europe
cheap viagra online uk
viagra bullshit
buy viagra online 35008 buy
buy drug satellite tv viagra
viagra breathing
cheap generic india viagra
buy discount viagra online
cialis 1
buy crestor online
discount viagra cialis
buy viagra meds online
buy viagra ups
buy online viagra viagra
soma online
buy generic viagra online pharmacy online
buy viagra online without prescription
cheap viagra kamagra
cheap quality viagra
cheep viagra from indea
buy viagra inte
buy viagra online u
order viagra on line
buy pharmaceutical viagra
viagra and discovery
buy viagra levitra alternative lavitra
cheapest in uk viagra
buy herbal viagra
order viagra onlines
viagra buying online
buy viagra and overseas
buy cheap viagra on the net
cheapest brand viagra
cheap levitra online
buy hgh canada
buy cheap deal pill viagra
order viagra buying viagr
buy plavix
discount viagra generic
viagra buy viagra
buy viagra for cheap
buy viagra in england
buy deal herbal viagra viagra
cheap referrers total viagra
buy cheap cialis generic levitra viagra
order site viagra
cheapest viagra us pharmacy
buy viagra online australia
buy viagra for women
buy kamagra
discount viagra mastercard
cheap discount viagra
cheep generic viagra
buy isoptin
cheap viagra discount viagra buy viagra
buy cialis without prescription
cheap viagra uk
cheapest viagra world
discount viagra viagra
buy viagra in the uk
buy viagra per pill
discount viagra or cialis
cheap overnight viagra
buy viagra now
discount viagra drug
buy lipitor
order order viagra
buy viagra order viagra
discount viagra offers
buy p viagra
cheap kamagra uk viagra
cheapest viagra online plus zenegra
cheap viagra 25mg
buy viagra without prescription
buy in uk viagra
buy generic viagra pharmacy online
buy levitra viagra online
cheap molde ticket viagra
cheapest price viagra
cheapest viagra us licensed pharmacies
viagra and coupon
buy viagra viagra online
order viagra with mastercard
cheap no prescription viagra
cialis online
buy viagra online web meds
viagra buy uk
cheapest price for viagra and cialis
viagra and cialis cheap
generic soma
buy cheao cgeap kamagra uk viagra
buy levitra online viagra
buy prescription viagra without
buy viagra no prescription
buy cheapest online place viagra
buy viagra online online pharmacy
purchase levitra
buy levitra now
purchase levitra online
order levitra online
cheap viagra no presrciption 50mg
buy viagra where
buy online p viagra
buy online purchase viagra
buy viagra 100mg
cheapest generic viagra caverta veega
buy cheap viagra 32
buy online viagra in the uk
viagra by mail
purchase tramadol online
discount viagra prescription drug
buy cheap site viagra
buy viagra zenegra
buy softtabs viagra
over the counter viagra substitute
order viagra online consumer rx
cheap levitra viagra href foro forum
viagra buy it
buy cheap crestor
buy viagra or cilas
order mexican viagra
buy now viagra
buy crestor
buy viagra australia
cheap mexico viagra
buy viagra online india
order viagra online a href
cheap viagra canada
cheapest generic viagra and cialis
buy viagra online no prescription
cialis 20mg
allegra d
cheap deal pill pill viagra
buy viagra online now buy viagra
viagra buy now pay later
buy lexapro
buy viagra alternative
cheap phizer viagra
viagra buy in uk online
order crestor
cheap drug online prescription viagra
generic zoloft
imitrex
buy deal deal price viagra
buy viagra in uk
viagra and deafness
buy viagra cheap through online sales
cheap prescription viagra without
cheap viagra in uk
buy viagra 32
cheap testosterone viagra href foro
buy keyword viagra
order zoloft online
cheap generic viagra substitutes
buy discount soma
buy viagra contact us page
buy canada viagra
buy viagra in mexico
buy australian viagra
cheapest line viagra
order discount viagra
cheap pharmaceutical viagra
order 50mg viagra
viagra buy contest
buy levitra
buy viagra online discount
tramadol cod
cheapest generic viagra and cialis pills
buy viagra online alternative viagra
order crestor online
buy viagra over the counter
buy dot phentermine viagra
buy deal viagra
cheap online generic viagra
buy online sale viagra
buy viagra cheap fed ex
buy avandia
buy glucophage
buy viagra in spain
cheapest prices on generic viagra
buy non prescription generic viagra paypal
zoloft online
cheap meltabs viagra
buy cheap discount lexapro
order viagra softtabs
buy viagra buy cheap viagra index
buy cipro
cheap genric viagra online
generic levitra
buy viagra toronto
cheaper viagra
buy depakote
buy free viagra viagra
buy cheap uk viagra
viagra buy general
cheap viagra cialis
cheap discount soma online
cheap generic viagra from usa
purchase crestor online
buy cheap discount pill viagra viagra
seroquel
cheapest viagra on line
buy viagra safeway pharmacy
buy cheap viagra online uk
cheap soft tab viagra
order status viagra
cheap testosterone viagra href foro forum
cheap drugs viagra cialas
buy now soma
buy crestor
cheap discount cialis
order pfizer viagra with mastercard
cheap viagra credit
cheapest generic substitute viagra
viagra buy australia
cheap viagra online order viagra now
buy viagra in bangkok
buy viagra over the counter us
buy cheap viagra online now uk
buy cheap purchase uk viagra
cheapest viagra and regalis
cheapest generic viagra 99 cents
buy cailis viagra singapore
cheapest viagra prices uk
cheap crestor
purchase crestor
order viagra prescription
viagra and flomax
buy followup post viagra
buy generic viagra online
buy online online viagra viagra
viagra buy
purchase paxil online
order viagra now
cheap viagra
buy carisoprodol no prescription
purchase nexium online
order viagra online in wisconsin
buy in spain viagra
cheap viagra index
over the counter viagra alternative
buy sublingual viagra on the internet
buy imitrex
order viagra overnight shipping
cheap viagra online prescription
buy cheap p viagra
buy viagra with paypal
viagra canada price
buy viagra line
cheap cheap viagra viagra
buy viagra in london
viagra by money order
discount viagra overseas
viagra by phone
buy viagra in toronto
buy cheap levitra
cheapest place to buy viagra online
check generic order pay viagra
buy uk viagra
cheap viagra from pfizer
buy online pill viagra
buy generic viagra si br
buy pill price price viagra
buy generic viagra usa
cheap gerneric viagra
buy cheap online prescription viagra
cheaper viagra levitra apcalis
buy cheap viagra online here
buy viagra phentermine online pharmacy
buy discount price sale viagra viagra
buy discount crestor
buy viagra online cheap
viagra buy do nu
buy viagra by pill
over the counter viagra
buy cheap viagra online now
buy evista
cheap herbal sale viagra viagra
buy cheap lexapro
buy viagra online 35008 buy viagra
buy viagra without prescription pharmacy online
lexapro side effects
buy cheap free online viagra viagra
buy cheapest viagra
cheap discount levitra
cipro 20
cheap viagra fast shipping
relafen
buy online prescription viagra without
buy can reply viagra
buy site viagra
cheap deal viagra
buy online order viagra
cheapest uk supplier viagra
buy viagra in amsterdam
cheapest viagra in uk che
buy cheap sale viagra
order viagra online no rx prescription
buy soma
discount viagra
buy diet viagra online
buy neurontin
buy viagra new york
buy now hgh
cheap discount crestor online
buy online viagra viagra viagra
cheap paxil online
buy levitra canada
buy prescription viagra
discount viagra perscription drug
cheap herbal viagra viagra viagra
buy cheap online uk viagra
buy viagra in united kingdom
buy cheap viagra viagra
buy coumadin
viagra and cialas
cheapest viagra on the internet
cheap discount crestor
cheapest generic viagra sent overnight
buy viagra online get prescription
buy locally viagra
viagra by mail catalog
cheapest viagra overnight