Google Gears meets Ruby on Rails

It has been a while since I posted something new. But I have a few articles in mind that I will post soon.

The first one is something that I discovered a few days ago. The fantastic toolkit Google Gears that enables webapplications to work offline has met RoR.

2 students, Michael Marcus and Rui Ma, have made it all possible. I haven’t had the time to play with it yet, but I’m working on a small project now that fits the need to experiment with.

The things I can tell is that they wrote some sort of a wrapper that to work with all the javascript api’s that Gears has. Next to that wrapper, you still need some javascript to work within the browser, but the syntax looks very ruby-ish.

Becouse crud-actions over http can be simulated, we can use the same views and controllers like we would use for a normal online application.

The two students hope they can make it available as a plugin soon, so it can be used in existing projects.

For more info, check out the Gears on Rails project page.

Comments

Firefox 3 out now!

Jej, it is finally here. Firefox 3 is out. I was waiting a long time for this release. I dind’t use the beta or RC versions, so it was a bit hard to wait. But it was worth it. One of the main things I couldn’t wait for was the fact that FF 3 would consume less memory.

Firefox 2 was consuming between 220.000 and 270.000k on my laptop. Now it only consumes between 40.000 and 70.000k. I haven’t take the time yet to test everything in detail.One thing I had problems with was Firebug. The 1.0.5 release doesn’t work under Firefox 3 and the getfirebug website is still down. But luckely I found a SVN build at MyZoneLabs that does the trick.

So do not hesitate and GET FIREFOX 3.0 . Don’t forget, the Mozilla Foundation is trying to break the Guiness World Record of most downloaded software in one day. So if you stumble upon this post before 17:00 UTC on June 18, 2008 and downloaded Firefox, you are one of the many who is helping to acheeve this goal.

Here is a changelog of FireFox 3.0

More Secure

  • One-click site info: Click the site favicon in the location bar to see who owns the site and to check if your connection is protected from eavesdropping. Identity verification is prominently displayed and easier to understand. When a site uses Extended Validation (EV) SSL certificates, the site favicon button will turn green and show the name of the company you’re connected to. (Try it here!)
  • Malware Protection: malware protection warns users when they arrive at sites which are known to install viruses, spyware, trojans or other malware. (Try it here!)
  • New Web Forgery Protection page: the content of pages suspected as web forgeries is no longer shown. (Try it here!)
  • New SSL error pages: clearer and stricter error pages are used when Firefox encounters an invalid SSL certificate. (Try it here!)
  • Add-ons and Plugin version check: Firefox now automatically checks add-on and plugin versions and will disable older, insecure versions.
  • Secure add-on updates: to improve add-on update security, add-ons that provide updates in an insecure manner will be disabled.
  • Anti-virus integration: Firefox will inform anti-virus software when downloading executables.
  • Vista Parental Controls: Firefox now respects the Vista system-wide parental control setting for disabling file downloads.
  • Effective top-level domain (eTLD) service better restricts cookies and other restricted content to a single domain.
  • Better protection against cross-site JSON data leaks.

Easier to Use

  • Easier password management: an information bar replaces the old password dialog so you can now save passwords after a successful login.
  • Simplified add-on installation: the add-ons whitelist has been removed making it possible to install extensions from third-party sites in fewer clicks.
  • New Download Manager: the revised download manager makes it much easier to locate downloaded files, and you can see and search on the name of the website where a file came from. Your active downloads and time remaining are always shown in the status bar as your files download.
  • Resumable downloading: users can now resume downloads after restarting the browser or resetting your network connection.
  • Full page zoom: from the View menu and via keyboard shortcuts, the new zooming feature lets you zoom in and out of entire pages, scaling the layout, text and images, or optionally only the text size. Your settings will be remembered whenever you return to the site.
  • Podcasts and Videocasts can be associated with your media playback tools.
  • Tab scrolling and quickmenu: tabs are easier to locate with the new tab scrolling and tab quickmenu.
  • Save what you were doing: Firefox will prompt users to save tabs on exit.
  • Optimized Open in Tabs behavior: opening a folder of bookmarks in tabs now appends the new tabs rather than overwriting.
  • Location and Search bar size can now be customized with a simple resizer item.
  • Text selection improvements: multiple text selections can be made with Ctrl/Cmd; double-click drag selects in “word-by-word” mode; triple-clicking selects a paragraph.
  • Find toolbar: the Find toolbar now opens with the current selection.
  • Plugin management: users can disable individual plugins in the Add-on Manager.
  • Integration with Windows: Firefox now has improved Windows icons, and uses native user interface widgets in the browser and in web forms.
  • Integration with the Mac: the new Firefox theme makes toolbars, icons, and other user interface elements look like a native OS X application. Firefox also uses OS X widgets and supports Growl for notifications of completed downloads and available updates. A combined back and forward control make it even easier to move between web pages.
  • Integration with Linux: Firefox’s default icons, buttons, and menu styles now use the native GTK theme.

More Personal

  • Star button: quickly add bookmarks from the location bar with a single click; a second click lets you file and tag them.
  • Tags: associate keywords with your bookmarks to sort them by topic.
  • Location bar & auto-complete: type in all or part of the title, tag or address of a page to see a list of matches from your history and bookmarks; a new display makes it easier to scan through the matching results and find that page you’re looking for. Results are returned according to their frecency (a combination of frequency and recency of visits to that page) ensuring that you’re seeing the most relevant matches. An adaptive learning algorithm further tunes the results to your patterns!
  • Smart Bookmarks Folder: quickly access your recently bookmarked and tagged pages, as well as your more frequently visited pages with the new smart bookmarks folder on your bookmark toolbar.
  • Places Organizer: view, organize and search through all of your bookmarks, tags, and browsing history with multiple views and smart folders to store your frequent searches. Create and restore full backups whenever you want.
  • Web-based protocol handlers: web applications, such as your favorite webmail provider, can now be used instead of desktop applications for handling mailto: links from other sites. Similar support is available for other protocols (Web applications will have to first enable this by registering as handlers with Firefox).
  • Download & Install Add-ons: the Add-ons Manager (Tools > Add-ons) can now be used to download and install a Firefox customization from the thousands of Add-ons available from our community add-ons website. When you first open the Add-ons Manager, a list of recommended Add-ons is shown.
  • Easy to use Download Actions: a new Applications preferences pane provides a better UI for configuring handlers for various file types and protocol schemes.

Improved Platform for Developers

  • New graphics and font handling: new graphics and text rendering architectures in Gecko 1.9 provides rendering improvements in CSS, SVG as well as improved display of fonts with ligatures and complex scripts.
  • Color management: (set gfx.color_management.enabled on in about:config and restart the browser to enable.) Firefox can now adjust images with embedded color profiles.
  • Offline support: enables web applications to provide offline functionality (website authors must add support for offline browsing to their site for this feature to be available to users).
  • A more complete overview of Firefox 3 for developers is available for website and add-on developers.

Improved Performance

  • Speed: improvements to our JavaScript engine as well as profile guided optimizations have resulted in continued improvements in performance. Compared to Firefox 2, web applications like Google Mail and Zoho Office run twice as fast in Firefox 3, and the popular SunSpider test from Apple shows improvements over previous releases.
  • Memory usage: Several new technologies work together to reduce the amount of memory used by Firefox 3 over a web browsing session. Memory cycles are broken and collected by an automated cycle collector, a new memory allocator reduces fragmentation, hundreds of leaks have been fixed, and caching strategies have been tuned.
  • Reliability: A user’s bookmarks, history, cookies, and preferences are now stored in a transactionally secure database format which will prevent data loss even if their system crashes.

Comments

Rails new template file extensions

For some of you that don’t know this yet (don’t be ashamed of yourself, I only heared about it a a few months back), Rails 2 recommends a new file extension for your template file.
At this point, everyone was using template extensions like:

  • .rhtml
  • .rxml
  • .rjs

To unify the template files, the Rails developers have come with a clever solution: chaning the template extensions so that they math up and tell you in what format they are.
By doing this, your new template extensions should look like this:

  • .html.erb
  • .xml.erb
  • .js.rjs

You are probably thinking: “everything looks alike now, except the rjs and haml templates. Why not using .js.erb?

Well, the answer is quite simple.

  • .html.erb -> response format is in HTML,  parsed with ERB
  • .html.haml -> response format in HTML, parsed with HAML
  • .xml.erb -> response format in XML, parsed with ERB
  • .js.rjs -> response format in JavaScript, parsed with RJS

If someone ever came up with a plugin that does the same Javascript actions for some templates. Those templates could be called .js.dudesplugin .

You see now? It all makes sence. Rails is all about convention, so it wouldn’t make sense to make an exception from the naming scheme for RJS templates.

Comments

Rails and foreign keys

There is one plugin that I use in all my projects, and that is the Foreign Key Migrations plugin from RedHill. Defining foreign keys can’t become easier then this. Since as far as I know, Rails migrations don’t set foreign keys in your database, so this is the best solution. It uses SQL-92 syntax and as such should be compatible with most databases that support foreign-key constraints.

You can even use it for legacy column names that don’t end with “id”. There is even a generator for creating foreign keys on a database that currently has none, so you can easily start using it even at the end of a project.

You can download the EDGE, 2.0 stable, 1.2 stable or 1.1.6 release, depending on your Rails version. Don’t forget the you need the RedHill on Rails Core .

Comments

Netbeans 6.1 Fast Debugger Bug

Yesterday evening, I installed Netbeans 6.1 since I use Netbeans for my Ruby on Rails development. When developing today, I wanted to use the debugger, but for some reason I couldn’t seem to install the Fast Debugger again. After some research on the Netbeans site, I came accross the answer.

Seems like there is a bug in Netbeans 6.1 that was discovered to late and ended up in the release. It will be fixed in a normal update, for the people that realy need the debugger (I guess every good developer), the fix is easy. Just uninstall the ruby-debug-base gem and install the fast-debugger-ide gem.

Everything is working perfectly now :)

Comments (2)

RESTful programming… but what does it mean?

I realy start to get into the Rails rabbit hole. The last 9 months or so, I’ve been working in some Rails projects for the company I work for during the day. I have learned a lot, but when reading other peoples blog, I still feel like a real Uber n00b. I started last weekend on a new project for Netronix . Since I wan’t this project to be like a future reference for other projects, I started to read a lot upon programming styles in RoR. One term that allways poped up was the REST. I saw it at the beginning when I just started to learn Ruby (and Rails) but never realy payed mutch attention to it. And it wasn’t mentioned even once in all of the Rails books that I read. So why bother.

For some reason, I just wanted to know what REST was. So I started the quest at your friendly neighberhood search engine Google . And yes, you get a lot of good hits, but also a lot of junk. During my quest of knowledge, I stumbled apon a nice PDF called RESTful Rails Development . Its not big, but it explains the whole theory in a playful way.

I could realy advice this light bedtime reading to everyone who has started learning Rails, and is just eager to improve his/her Rails skills.

So this weekend I’ll start on refactoring my project. Hopefully it will pay of soon :) . Maybe RESTful programming will become a second nature :)

Comments (1)

Analising and Unit Testing: A crusial part of development…or not

When I first started programming (started with Turbo Pascal and then Visual Basic), I realy enjoyed programming. It was a whole new world opening up for me. Whenever I needed a piece of software to make my life easier, I just sat down in front of the computer and started programming like crazy. VB was a sequential programming language where you could reuse functions by the use of modules, etc. It was fun to use and you could have a finished application within a few hours.

Then came the new hype, Object Oriented programming. The new hype, a new sherif in town. Offcourse when I started at college, we saw Java. I have to admit I had to get used to the idea of OO programming after being a sequental programmer for years. We also had a class where we learned how to analise our projects and manage them in a professional way. Put that class together with Java, and you had a few hours of sleep (if people even bothered coming to class). It was just so boring, I couldn’t see myself as a programmer. Having to analise everything into detail, and using unit tests to test your application, or even develop by the TDD method (Test Driven Development, witch means writing tests first, program later).

For my internship, I chose for the company AMI Semiconductor (now known as ON Semiconductor).  I had to develop some Testing tools for the Test Methodology Departement. After 4 months of intership, I still didn’t feel like developing. I didn’t have to analise everything (they where very loose on that mather), but Java just didn’t got my mojo running.

Then for some twisted reason, I stumbled into the world of web development. Using PHP, but mostly Ruby (On Rails), I wouldn’t change for anything else. I’m allready working for 8 months as an Information Architect, and I’m starting to realize, that the things they thought us about analising and unit testing wasn’t to let us fall asleep. Lately, I’m starting to realize that it is realy nessessary to have a good analisis before you start a project, and having some Unit tests wouldn’t be that bad.

I have finished a few projects at my day job as an Information Architect, and there are a few things that I would have done differently.  One of them would be to have a clearer view of the project. Not everything was analised, witch has become a real pain in the ass now. The client keeps on asking stuff that realy requires huge changes to the system. And after a few months, I realy want to put this project behind me. Second thing is to take some time to create tests. I start to believe they could realy help me keeping my code clean and bugfree.  Offcourse, that’s not only up to me. Some projects have a tight deadline, and a small budget, so the first things that get cut are analising time and time for unit testing (creating proper tests can take time, so they say…).

I still haven’t created a single test. But I have a new project comming up, witch I’m going to develop for Netronix  (my own company) .  And I can assure you, I will analise everything properly, not loosing the target of sight and even start to develop unit tests. This way,the project just can’t go bad and get sore. I don’t think I’m going to go for TDD (Test Driven Development), becouse I know I don’t have the discipline yet for doing that. But maybe in the future, when I get more experience, I’ll give it a shot.

So how about you other developers, do you take time to create unit tests and analise everything enough so you don’t lose focus on the goal? Maybe you guys can give me some pointers on how to write Unit Tests. I allready read some books, but having some practical advise would help me more out, then some theoretical rules.  My next personal project will be written on the Rails framework (sorry Symfony guys, but I think Rails will fit my needs better this time), so some Rails tips would even be better.

So when I can finish my project in success with a strong bataljon of unit test, I maybe can convince my boss to start creating unit tests for all our projects…well, I guess I’ll have to wait and see

Comments

GTA 4 is out

Everybody has waited a long time for this, but it’s finally here: GTA 4. I’m one of the lucky gamers that allready had his hands on a copy. Here in Belgium, the Game Mania stores opent here doors to start the sale at exactly 00:00 h. I have to admit, I was surprised of all the people that where there. We where with more then 50 people at the store in Oudenaarde.

I can’t say mutch about the game yet. I only got home around 1 am and just played the first few “missions” to get the hang of it. But my first impression is that this will most likely be the best GTA ever, although I have to get used to the more realistic graphics and new controls.

I’m still waiting for some sales numbers. I’m pritty curious how many copies have been sold for PS3 and Xbox360  (I bought the PS3 version, since I don’t own a Xbox 360).

I can’t wait to play more tonight. Next game in line is Metal Gear Sold 4 :)

Comments

Total Freedom

Last weekend I drove a friends motorcycle. A Honda CBR 125. Not that it is such a big racing machine, but it’s the only thing closest to a real motorcycle I can ride here in Belgium with only a car permit. Since he hot his motorcycle drivinglicense, he could use his fathers motor and he suggested to cruize a bit around. I have never driver a motorcycle before, so I was a bit nervous at the beginning. But after driving a few hours in the city, I got the hang of it.

So we decided to make a little trip. We found a roadbook in the net that took us to some cities not too far from where we live. And I have to admit, it was great. I never thought riding a motorcycle could be so mutch fun. You feel totaly free when driving through some nice landscapes, just enjoying the good weather and the nice view. I was pritty impressed with the Honda. For a 125 motocycle, it still has a lot of power for such a small engine. Offcourse, it tops around 110 – 120 km/h. But still, the speed limit here in Belgium is a maximum of 120 km/h on the freeway, 70-90 km/h on secondary roads and 30-50 km/h in city limits. So the Honda CBR is enough for normal roads and a nice motorcycle to learn driving a motorcycle.

This weekend, the weather should even be better, but I have no idea if I’m going to ride again. It is a lot of fun, but if you are away all day, you can’t finish any work. And my workload is getting to a peak. But again, I realy start to miss the feeling of true freedom…

Comments

Why I switched to Doctrine

As I said in my previous post, I would tell more about why I switched to Doctrine. I mainly started to think about the idea when I first heared that we were going to start a new project in Symfony at work. The lead developer decided to go for Doctrine ORM instead of Propel. So I wanted to know why go went for Doctrine. I allready knew that Doctrine is way faster then Propel 1.2 and it has more possibilities, but I just wanted to hear it from him. And I have to admit, he had good arguments.

The verbosity of the Doctine code is way better then Propel. The model mappings (in line of XML files or YAML) are bigger for Propel then for Doctrine, and in Doctrine you can do everything in PHP instead of using external files (consolidated code is a huge plus).

The API of Propel is also “time-consuming”. Check the following Propel code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$c = new Criteria();
 
$cton1 = $c->getNewCriterion(AuthorPeer::FIRST_NAME, "Leo");
 
$cton2 = $c->getNewCriterion(AuthorPeer::LAST_NAME,
array("Tolstoy",  "Dostoevsky", "Bakhtin"), Criteria::IN);
 
$cton1->addOr($cton2);
 
// add to Criteria
 
$c->add($cton1);
 
$authors = AuthorPeer::doSelect($c);

with this Doctrine code:

1
2
3
4
5
$authors = $conn->query("
 
FROM Author a WHERE a.first_name = ? OR a.last_name IN ?
 
",array('Leo',array("Tolstoy", "Dostoevsky", "Bakhtin"));

Propel doesn’t support his own query definition language like Doctrine, so every query has to be done through time-consuming API calls (and Doctrine also supports a object oriented API, so it is available if you need it). But it gets a lot more uglier if you when you need associations and eager loading in your queries, what can be run smoothley in Doctrine.

Doctrine supports 3 types of inheritance that you find back in Hibernate, where Propel is only limited in single-table-inheritance. This can be very usefull in the implementation of complex systems.

Doctrine support a sort of mixins (this at the act_as_* plugins of ActiveRecord), in a language that doesn’t support mixins :) . Even think about the “event listeners” like the before_save etc methods in ActiveRecord. (long live Rails right )

Doctine even supports migrations, and in the near future, they even will have automatic migrations (change the model definition, run auto-migrate and the DB is updated).

Some other nice features are full text searching, query/result caching, magic finders ($table->findOneByName), etc.

Doctrine is build in a logical way, the pragmatic use of ActiveRecord mixed with the power of Hibernate.

So be honost, I someone would tell you all the above, wouldn’t you just make the switch immediately?!?

Comments (3)

Next entries » · « Previous entries