Archive for the 'Science & Technology' Category

Coding Aloud – Restricting your users to edit other’s profile

restful_authentication plugin made its way to my projects as the “de-facto” authentication system in my Ruby on Rails projects like w2task or gistate.com. I would not insist on how to install it, as it is well explained on its home page at github.

What I want to show is that in particular instances we may not like that one user can access and modify other user’s profile. For example if I try to edit my profile, the URL will end in something like users/2/edit and if I would change it to users/1/edit then I am able to modify this user – most often an undesirable fact.

Here is my workaround:

app/controllers/users_controller.rb
  # ...
  def edit
    if params[:id].to_i == self.current_user.id
      @user = User.find(params[:id])
    else
      flash[:error] = "Not allowed!"
      redirect_back_or_default('/')
    end
  end
  # ...

That’s pretty much everything I need to change.

What is your preferred solution? Are you doing these tests into a – perhaps – before_filter?

w2task Challenge

I would like to introduce my latest project w2task – a web application written in Rails.

w2task challenge

It is a task and time management web based software. At this point, a registered user can create its own business (company) and define a series of projects. Then, the user can record its own efforts and attach them to a particular project. The sidebar (Efforts Bar) gives a quick statistic regarding the number of efforts and total timing. Also, by clicking on a particular project you may get the timesheet of the particular month.

You may well give it a try, here is the link: http://w2task.com. Don’t hesitate to tell me your opinion about it, right here as a reply to this post. You may me as harsh as you want, it is constructive and ultimately this blog is moderated 🙂 .

Be warned, this web app is still in its early, early development stages.

To better understand the philosophy behind this application, the strength and the weaknesses of the application, allow me to tell you in few points a bit of my history with Rails:

  • January 2008 – I’ve bought my first Rails book Agile Web Development with Rails, but I didn’t have enough time to practice it that Rails, turned 2.0 and broke the compatibility with 1.x versions. I remember the headaches regarding the scaffolding, so I abandoned my Rails path.
  • May 2008 – I’ve make up my mind and bought the third edition of the above book and start again with Rails at a low pace.
  • October 2008 – my friend Hossein asked me to join in a web project with a real estate portal. I thought it is the moment to put my knowledge into practice and this his how gistate.com got wind. Ok, the real estate market is down now (dec 2008 – jan 2009), but gistate.com shines 😉 .
  • November 2008 – Dubai Hacking Night – where I meet again my heroes: the SpinBits guys which encouraged me to learn Rails. I have shown to Rida a sketch of w2task (a scaffold and some CSS files) – a Ruby on Rails practicing project and he asked me to promise that I will present it on DemoCamp 4, which should be in mid January 2009.
  • December 2008 – I have closely followed 37signals blog and read their book – Getting Real. Truly inspiring, and I am thinking to copy their business model.
  • 2009 – here we are.

Wow, getting long with this post. However, for the future, I have a lot to say and I hope it will be of interest for my blog readers, as I will fly along the Rails.

DemoCamp Dubai (third edition)

The third edition of DemoCamp Dubai is now over. It was a beautiful evening, with four different presentations:

  1. Jawaker – online card games
  2. Twffaha – women recruitment portal
  3. Untiny – expand tiny urls
  4. industrials Directory – self explanatory title
For more details, I will refer to DemoCamp Dubai website.
And because we all like criticizing, please allow me adding the following comment. Rules, rules, rules … Rule #2 of DemoCamp: No powerpoints allowed. Why no .ppt ? Well, do you have working software or don’t you? But first three presentations used quite heavily the power of slides.
However, all in one… great people, great projects.

Title: Nokia E90 – How To Find its MAC Address?

Dial:

*#MAC WLAN#

or

*#62209526#

Ubuntu 8.10 Countdown

Yes, I admit, I am on a Mac, but still I am envious on my first love
– Linux with an Ubuntu flavor.

Here is a Ubuntu 8.10 countdown icon. Enjoy!

Large Hadron Rap

Rappin’ about CERN’s Large Hadron Collider!

Changing the MAC Address on Mac OS X

All we need is to type this in Terminal

sudo ifconfig en0 lladdr 00:00:00:00:00:01

or

sudo ifconfig en0 ether 00:00:00:00:00:01

Just change 00:00:00:00:00:01 with the MAC address we need.

It seems that for older versions of Mac OS X (prior to Tiger – OS X 10.4) we will need this patch:  http://slagheap.net/etherspoof/ .

Speedtest widget updated

Open-source economics – with Yochai Benkler

DemoCamp Dubai (Second Edition)

Yes, I have been there, and I really enjoy it.

What is all about? Presentations of web applications (a total of four on this edition) plus a session of question and answers at the end of each presentation.

This way I could learn about trends in web development, I could figure out which platforms are in use, and I have been carefully listening to the answers of “What is your business model?”. This is because I am myself involved in such a project called Dine In UAE (dineinuae.com), and I am looking for effective solutions to bring it back to life.

But to my surprise the most applauded project didn’t have any business model behind (http://www.wasfati.com). It was created with passion, evolving from a simple blog gathering Middle Eastern food recipes, to a food and nutrition portal, with plans to become a social website, whilst keeping its main purpose.

The other projects presented are:

  • http://darrb.com – delivery by third party, users register and request for some items, and darrbers are delivering those items. Business model – a planned darrber fee.
  • http://logta.com – presenting hot deals in UAE, a portal where you can find out where are best prices for selected items. Business model – classified – which provoked some protest whispers – reminding that we were in a “democamp”, not a “marketingcamp”.
  • Swalifcast – an interesting concept, YouTube like, but focussing on educational screencasts (arabic only).

In the end, we had some food and could make friends. This is how I met the guys behind places.ae and spinbits.com. I like their way of thinking and hope we can become friends, especially because we are embracing now Ruby on Rails technology as our favourite development platform, and should be in contact via Ruby on Rails Dubai Groups: rails.ae and the Google Group.