Feeds:
Posts
Comments

Efficiency with Rails

Sometimes, I can’t believe the amount of work I can accomplish with Ruby on Rails. Today, I finished coding a RSS feed aggregator that generates aggregated RSS feeds for a Joomla web site (it merges posts from multiple feeds into one single daily feed for Joomla).

  • Import/export tab-delimited list of channels
  • Fetch RSS posts and converting the content to UTF-8 encoding (if necessary) (all major RSS formats) in background at regular intervals (daemon)
  • Show a list of all posts published today (taking into account the timezone)
  • Present that list in Atom format
  • Manually add/edit/destroy a channel
  • Show the raw channel content in XML format (to spot conversion errors if any)
  • Store the channels and posts in a database
  • Add a “source” element for each post in the aggregated feed that I generate
  • Modify the Joomla renderer to display the source of the post
  • Provide a way to stop/start the posts importer running in background
  • Set-up CentOS server for hosting the Rails application
  • Deploy to production server using Capistrano
  • Integrate a nice CSS template
  • Include basic http authentication for a single administrator
  • List all the posts in the database, with pagination
  • Provide a nice 2-level navigation menu
  • Store source code into Subversion

It took only 19 hours to do all that.  And it could have been faster if rendering the aggregated feed in Joomla would have been a lot easier (SimplePie does not support the “source” tag in RSS 2, but it does in Atom).

Thanks to the following open source contributions which made me save lots of time:

I’m very happy with the result.  I wonder if the same results could be achieved using another framework, such as .Net or PHP, in the same amount of time.  I think it would take more time, but hey, my opinion is biased.

Long live to Ruby on Rails!

Any comment?

Yesterday, I migrated to Snow Leopard.  After a day of file transfers, disk formatting, apps installation, password and license keys recovery, I finally was ready to install the Rails stack.  It’s great to do a clean install, we can get rid of the crap that was installed in the last 2 years.

Today, I spent a few hours on the Rails stack.  And I ran into some problems that I need to share with you because I didn’t find an answer on the net.

Background

I had to install the Rails stack, the framework I use in most (if not all) my projects.  The challenge was that I still have a few Rails projects that run under 1.2.x.  And Rails 1.2.x is not a good friend of Ruby 1.8.7, the version of ruby that ships with Snow Leopard.

Back on Tiger, I was using the amazing Locomotive application, which was a way to have dedicated environments for rails applications.  Then, when I moved to Leopard, Locomotive was not supported and I had to deal with all the apps sharing the same gems, same ruby and same everything.  Fortunately, ruby 1.8.6 was handling my Rails 1.2.x projects properly. I was also unsing Capistrano 1.4.2 along side 2.5.2 to deploy those old projects (i.e. cap _1.4.2_ deploy_with_migrations).

Now on Snow Leopard, I wanted to keep this flexibility.  I looked at different ways to set-up Rails on my Macbook Pro (Core 2 Duo).  The one on the Rails wiki was interesting, and I was used to this set-up, but I wanted to do a bit more.  I remembered that a new package manager was borned this year: homebrew.  I heard some good things about it.  And my last wish was to have multiple versions of Ruby on my system. This guide was a really good “instructor” on using RVM, the Ruby Version Manager.  Using RVM, you can have ruby 1.8.6, 1.8.7, 1.9.1 and even jruby and ree (Ruby Enterprise Edition).  This is cool, I will finally have a chance to start testing with 1.9.1 and eventually start new projects with it.

So I installed all that using my own recipee (which follows next), and everything was working fine with Ruby 1.8.7 and Rails 2.3.5.  When I started to use Ruby 1.8.6, my rails apps were hanging so bad, I was forced to “kill -9″ the processes (CTRL-C was not working).  Anytime the Rails environment was loading, the process would hang.

After a few hours of investigation, I found out that the problem was with RMagick.  And the problem was due to the use of NSLinkModule functions in dln.c (ruby 1.8.6 source code). Thanks to RVM, we have access to the source code of ruby. After applying a patch to ruby 1.8.6, as described in the bug report, everything started to work.

So here we go, follow me through the installation of the Rails stack on Snow Leopard.

Note 1: I did a clean install of Snow Leopard.  Not sure that my recipe will work on a Snow Leopard migration.  It might, but you will have to reinstall some 32-bit gems that compile some binary stuff.

Note 2: I’m using Textmate.  If you are using Aptana, you might want to check on the web, I think I’ve seen some blogs describing some issues with RVM and Aptana.  According to this post, starting Aptana from the command line makes it use the RVM interpreter.

Note 3: Phusion Passenger is awesome.  But in the past, I tried using it on my development machine and I didn’t like it so much.  I still prefer starting the server myself and see the output in my terminal window.  RMV supports Passenger, but I didn’t play with it.

Prerequisites

  • If you are still on Leopard, prior to migrate to Snow Leopard, find an empty drive and use SuperDuper to clone your hard drive.  This is an excellent backup solution (you can boot from the backup drive).
  • Format your drive and installer Snow Leopard.
  • Get the latest version of XCode on the Apple Developer Site and install it.

Homebrew

We could use MacPorts, but Homebrew takes less space (it uses what we already have on Mac OS X) and it does not require being root.  And Ryan Bates recommends it.

As mentioned on Homebrew’s wiki, you can install it anywhere, but lots of 3rd party solutions expect to have things in /usr/local. And Homebrew’s files are well isolated and the uninstall is well documented.  So there is no danger installing it under /usr/local.

So let’s change the owner of the /usr/local folder (otherwise, we always have to switch to super user).  I know, this is not standard practice, but hey, we’re on a mac and most likely you will be the only one using stuff in /usr/local.

sudo chown -R `whoami` /usr/local

Then, let’s install Homebrew (just one line, isn’t that great?).

curl -L http://github.com/mxcl/homebrew/tarball/master | tar xz --strip 1 -C /usr/local

Basic packages

Now let’s install some basic packages that we all love and cherish.

brew install readline
brew install git
brew install wget
brew install imagemagick

You have to agree that this is cool.  No sources to download and untar, no configure to run, … Homebrew takes care of doing all that.  Of course, we don’t have as much control, but this is fine with me so far.

MySQL

I’m still using MySQL (although Postgresql is on my R&D to-do list for 2010).  It’s installation is well documented.  You can download a disk image from the MySQL web site or compile the source code, or simply use Homebrew:

brew install mysql
mysql_install_db
sudo chown `whoami` /var/mysql

I also like to apply some changes to the default configuration. Here’s my /etc/my.cnf file:

[mysqld]
#Max packetlength to send/receive from to server.
max_allowed_packet=64M
socket = /var/mysql/mysql.sock
character-set-server = utf8
default-character-set = utf8

#This option makes InnoDB to store each created table into its own .ibd file.
innodb_file_per_table

[mysql]
default-character-set = utf8

[client]
socket = /var/mysql/mysql.sock
default-character-set = utf8

Then, let’s start the server and also install the launcher.

cd /usr/local/Cellar/mysql/5.1.41; /usr/local/Cellar/mysql/5.1.41/bin/mysqld_safe &
launchctl load -w /usr/local/Cellar/mysql/5.1.41/com.mysql.mysqld.plist

Ruby Version Manager (RVM)

Now that we have the foundation installed, let’s implement the Ruby Version Manager.  RVM keeps multiple ruby environments isolated from each other.  Each one has its own ruby version (compiled from source) and its own gems (which is awesome).

So instead of using the Snow Leopard out-of-the-box Ruby , let’s set-up an environment for 1.8.7.

But first, let’s install RVM (replace USER with your username):

gem install rvm
echo "if [[ -s /Users/USER/.rvm/scripts/rvm ]] ; then source /Users/USER/.rvm/scripts/rvm ; fi" >> ~/.bash_login
rvm install 1.8.7
rvm use 1.8.7

This will install everything in the .rvm folder in your home. If you change your mind later, it’s easy to uninstall: rvm implode.

You can confirm the installation by running rvm list.

Gems

RVM will install a version of Rubygems for each environment, with the proper gem sources (yes, gemcutter is already in the list). We have to install all the gems we need for each environment. Let’s install the common ones:

gem install ruby-debug
gem install capistrano
gem install rmagick
gem install sqlite3-ruby
gem install mongrel
export ARCHFLAGS="-arch i386 -arch x86_64"
gem install mysql -- --with-mysql-dir=/usr/local --with-mysql-config=/usr/local/bin/mysql_config
gem install rails
gem install manalang-bdoc

Now, to really see the power of isolated environments, launch bdoc from the command line.  See? Only the gems that we just installed.

Then, you can install additional gems, or go into one of your Rails 2.x project and issue rake gems:install.

Ruby 1.8.6

Now that we have ruby 1.8.7 working, let’s install version 1.8.6 so that we can do maintenance in our old Rails projects running under 1.2.1. And let’s make 1.8.7 the default interpreter when we open a new bash session.

rvm install 1.8.6
rvm 1.8.7 --default
rvm use 1.8.6

Now, we have to install a backport from ruby 1.8.7 (patch) so that we can use RMagick under ruby 1.8.6 on Snow Leopard. I suspect that it also fixes some other weird bugs.

rvm use 1.8.6
cd ~/.rvm/src/ruby-1.8.6-p383
wget http://redmine.ruby-lang.org/attachments/download/580 -O dln.patch
patch dln.c dln.patch
make
make install

Finally, let’s install the gems that we need.

gem install ruby-debug
gem install capistrano -v 1.4.2
gem install rmagick
gem install mongrel
export ARCHFLAGS="-arch i386 -arch x86_64"
gem install mysql -- --with-mysql-dir=/usr/local --with-mysql-config=/usr/local/bin/mysql_config
gem install rails -v 1.2.1
gem install manalang-bdoc

And that’s it. We now have 2 isolated interpreters and their gems. We are now in business for eventually migrating some projects to ruby 1.9.

Candies

There is a way with RVM to automatically switch interpreter when you cd to a project’s folder.  Simply provide a .rvmrc file in the project’s folder:

echo "rvm 1.8.6%projecta" > ~/projects/projecta/.rvmrc

Also handy is to have the current interpreter displayed in the command line prompt. Simply edit your ~/.bash_login file and add the following line:

export PS1="\$(~/.rvm/bin/rvm-prompt) $PS1"

Have fun, and continue to enjoy Ruby on Rails.

Pour la première fois depuis mon arrivée sur Twitter, j’ai décidé de ne plus suivre un collègue.  Quand le gars envoie 88 tweets plus ou moins pertinents à mes yeux, et ce dans une journée, je considère ça comme du spam et ca m’agresse.  Donc allez hop, good bye!

Mais y a-t-il un nombre de tweets par jours “politically correct”?  J’ai fait ma petite recherche et j’ai trouvé ceci (source):

  • Entre 10 et 20 par jours – et avec de l’information pertinente – vous êtes un bon twitterien.
  • Entre 50 et 75, soyez avisé que si vous tweeter des niaiseries, ceux qui vous suivent vont se tanner assez vite merci.
  • Plus de 75?  Comme 88 par exemple? aucune mention dans l’article! ;-)

Autres statistiques fort intéressantes, comme par exemple le nombre moyens de followers.

On peut maintenant se poser la question: mais où donc les twitteriens trouvent-ils le temps à consacrer à Twitter?  En d’autres mots, combien de temps passent-ils sur Twitter par jours?  Attachez votre tuque:  en moyenne 2.75 heures par jours (selon cette étude)!

Sortons notre calculatrice… ;-)

En date d’octobre 2009, il y avait 18 millions de twiterriens (source).  Posons les hypothèses suivantes:

  • salaire annuel moyen de 44000 $US (selon wikipedia)
  • supposons une semaine de 35 heures de travail, donc 7 heures par jours
  • ainsi, le salaire horaire est de 24.18$
  • sur les 2.75 heures, supposons que seulement 1 heure est utilisée durant les heures de travail
  • enlevons la tranche 15-19 ans (31% des utilisateurs) qui sont en majorité étudiants

Qu’obtient-on? Les entreprises “investissent” 300 millions $US par jours en temps d’employés sur Twitter!  Espérons que les retombées sont là!

Et on ne compte pas la possible perte de concentration tout au long de la journée, pour ceux qui “checkent” constamment Twitter.

Mais il faut aussi avouer que de temps en temps,  on trouve sur Twitter de l’information qui peut bénéficier à notre entreprise/employeur.  Ce n’est donc pas du temps perdu à 100%.

Mais tout de même, comme dirait André Ducharme de RBOs dans un de leur sketches:  “Pensez-y”!

MAJ

Voici quelques suggestions sur l’utilisation de Twitter, pour ceux qui ne veulent pas “sombrer dans l’enfer de la drogue” de Twitter. ;-)

Je suis de retour de la conférence de Michelle Blanc (powerpoint) sur les médias sociaux, domaine qu’elle maîtrise à perfection, conférence qui fût organisée par La Toiles des Communicateurs. Ce fût un très bon condensé de tout ce qu’on peut retrouver sur le blogue de Mme Blanc, blogue que vous vous devez consulter si vous ne l’avez pas encore déjà fait.

Pour les impatients, voici en raffale une liste des petites notes que j’ai pris durant la conférence et des liens vers quelques billets de Mme Blanc.

  • Le contenu web est important.  Plus tu as d’information, plus tu es “quelqu’un”.  Ainsi, les archives d’un blogue sont précieuses.  Et plus un blogue a de contenu, plus Google le considère comme un site important.
  • La voix des internautes compte beaucoup ces temps-ci et c’est la grande peur des entreprises.
  • L’honnêté est payante.  Elle a cité l’exemple de Cisco qui a engagé ses clients par le web pour régler les problèmes de ses produits.  (billet).
  • Jadis, le pouvoir était dans la main des manufacturier (via la publicité, le placement de produits en magasin, …).  Maintenant, le pouvoir est entre les mains du consommateur.
  • L’industrie du sexe innove beaucoup dans le monde du web.  Allons voir ce qu’ils font, ca peut nous indiquer vers où en s’en va. (billet)
  • Les entreprises investissent de moins en moins dans la publicité traditionnelle et de plus en plus sur internet.  Voir le graphique dans sa présentation. (billet)
  • Il ne faut pas juste avoir un site web ou un blogue.  Il faut que des sites d’autorité pointent vers nous.  Le réflexe du consommateur n’est pas toujours de faire une recherche Google.  Il va souvent commencer par les sites d’autorité comme Protégez-vous, PCMag, MacWorld, un ordre professionnel, … (billet)
  • Les réseaux sociaux sont découpés géographiquement, socialement et fonctionnellement.  Il faut donc avoir une présence sur plusieurs d’entres eux selon nos objectifs d’affaire.  Voici une carte que j’ai déniché qui donne un portrait global.
  • Twitter: même pas 2% des québécois sont sur Twitter, mais par contre, ce sont les gens les plus influents qui y sont.  Il ne faut donc pas négliger notre présence sur Twitter.  Et Facebook est “over hypé”. (billet)
  • Twitter: les messages qu’on peut considérer comme “insipides” peuvent éventuellement servir à solidifier une éventuelle relation d’affaire.
  • La gestion de la présence d’une organisation sur internet devrait être vue comme une entité à part entière dans l’entreprise, et non pas comme une fonction du service de marketing, des relations publiques ou autre.
  • Le roi des médias sociaux reste et restera encore pour longtemps le blogue.  Le blogue permet la notoriété, Twitter et Facebook la portée.
  • Mettre en place un blogue peut coûter entre 3 et 5K, et si on veut un “design fucké”, rajouter entre 5 et 10K.
  • Vos photos sur votre blogue ou Flickr: donnez-leur un nom.  Il n’y a pas grand monde qui cherche pour 123.jpg!
  • Le blogue devrait être un sous-domaine de votre site web.  Ca aide le référencement. (billet)
  • Et ne faites pas un blogue bilingue.  Faites-en deux: un en français, l’autre en anglais.  (aille, je fais dur sur ce point!)
  • Un blogue, ca peut aussi servir à l’interne d’une entreprise, comme par exemple un blogue pour le groupe social.
  • Et un Wiki, ca permet d’organiser de la documentation et de la maintenir à jours.  Encore une fois, ca devrait être un sous-domaine.
  • Lululemon: voici un bon example de l’utilisation des médias sociaux. (billet)
  • Avoir une mentalité de transparence dans notre contenu. (billet)
  • Et soyez généreux.  Ca ne vous enlèvera pas de travail, au contraire à la longue ca vous amènera des affaires. (billet)
  • Quel est le secret pour générer du bon contenu?  Ayez une passion et n’ayez pas peur de la polémique. (billet)

Guignolée du web

Voilà pour mon petit résumé.  Vous trouverez tous les détails du monde facinant des réseaux sociaux en consultant de site de Michelle Blanc, que je tiens à remercier pour avoir “donner” cette conférence.

Vous pouvez visionner la conférence dans son intégralité, une gracieuseté de TÉLUQ et La Toile des Communicateurs.

MAJ

Compte-rendu de Denis Gilbert, organisateur de l’événement.

It’s a quarter to midnight and you are just about to deploy a new version of a web site that has a totally new hierarchy.  This happens a lot when migrating a PHP site to Rails.  And then you realize that the structure or the URLs is totally different than the one on the old site.

Maybe the old site has a nice ranking in Google and a good reputation or lots of people have bookmarked pages of the site.  You don’t want to make Google and those users unhappy.  So you want to have the new web site send a 301 reponse code (permanent redirect) instead of the famous 404 (page not found).

One way to do this in Apache is to enable the rewrite engine and add some rewrite rules in the web site configuration.  But these rules are not easy to build and it involves changing the Apache config, which is not trivial for some people.

I found a Rack middleware called Rack::Rewrite that can take care of the redirections.  I find this solution interesting because it is web server agnostic (will work with Apache, Nginx, …).  Although the performance is not as good as having rewrite rules at the web server level.

First, you need install the gem:

sudo gem install rack-rewrite

Then, you want to include a reference to the gem in config/environment.rb:

config.gem 'rack-rewrite', '~> 0.2.0'

Then, we need to load the middleware in the rails stack of our application.  Instead of putting this in the environment.rb file, I prefer to put it in an initializer (config/initializers/rack_rewrite.rb) since we will also include the redirection rules in this file:

ActionController::Dispatcher.middleware.insert_before(Rack::Lock, Rack::Rewrite) do
  r301 '/fr/rates_and_packages', '/fr/services-et-tarifs'
  r301 '/en/rates_and_packages', '/en/services-and-rates'
  r301 '/fr/information', '/fr/renseignements/horaire-et-coordonnees'
  r301 '/en/information', '/en/informations/business-hours-and-location'
  r301 %r{\A/index.php}, '/fr'
  r301 %r{/en/index.php}, '/en'
end

As you can see, the first rules look for a perfect match. The last two rules apply a regular expression to the request URI. This is really cool when a bunch of old URLs have a similar structure and share the same redirection URL.  There is a rewrite command that allows to transform the URL and pass it down the Rails stack.  See the documentation for more options.

Now, how do you find out what are the old URLs you need to redirect?  Well, you can go on the old site and manually crawl the site.  But I prefer to use a simple ruby crawler called Anemone.

sudo gem install anemone

Then write some ruby code and run it.

require 'rubygems'
require 'anemone'

Anemone.crawl('http://www.awebsitetocrawl.ca') do |anemone|
  anemone.on_every_page do |page|
    puts page.url
  end
end

It will give you a list of all the URLs found on the given site. Though it does not work if the site is using Flash menus (normally, such sites should have regular navigation menus somewhere on the page for SEO purposes, but I’ve seen some sites that don’t).

That’s it. A simple way to generate redirection codes. There is a more complete solution named Refraction that you can use as well, but I am satisfied with the straight forward Rack::Rewrite solution.

Here you go, hoping it helps you in your Rails project.

J’ai un bon réseau de contacts dans LinkedIn et je désirais savoir ceux qui étaient dans Twitter pour possiblement les suivre sur Twitter.  A ma grande surprise, je n’ai rien trouvé pour “facilement” faire ça.

Voici donc une méthode manuelle pour y arriver.

  1. Dans votre profile LinkedIn, cliquez sur “Contacts” dans le menu à gauche pour voir la liste des tous vos contacts.
  2. Au bas de la page, cliquez sur “Exporter la liste de mes relations”.  Choisissez le format “Microsoft Outlook”.
  3. Ensuite, accédez à votre compte Gmail (ou Yahoo).  Si vous n’en n’avez pas un, ca ne coûte rien de vous en créer un.
  4. Cliquez sur “Contacts” à gauche dans Gmail.
  5. En haut à droite, vous allez voir un lien “Import”.  Cliquez ce lien et choisissez le fichier qui a été généré à l’étape 2.
  6. Sur Twitter.com, assurez-vous d’avoir ouvert une session et cliquer sur “Find people” au haut de l’écran.
  7. Cliquez sur “Find on other networks” et sélectionnez Gmail.
  8. Entrez vos informations Gmail et cliquez sur “Continue”.

Twitter va ensuite accéder à vos contacts Gmail et regarder si ils ont un compte sur Twitter.  Il vous affichera ensuite la liste et vous demandera de choisir ceux que vous désirez suivre sur Twitter.

Voilà, en espérant que ca vous aide!

Hugo

Western Digital My Book Studio Edition 1TB

Western Digital My Book Studio Edition 1TB

It’s been a while since my last post, but the problems I had this week-end deserve a blog post just in case someone would run into the same crazy hard drive problems.

Conclusion: if you buy a Western Digital My Book Studio Edition already formatted for the Mac, don’t believe them and reformat the drive before using it as a scratch drive in Final Cut Express.

Conclusion: don’t buy the My Book Studio Edition 1TB for use with Final Cut Express.  U suspect the one I got was not a 7200rpm drive and that the controller is not bullet proof with Mac OS X.

UPDATE 1: after capturing 2.5 hours of video, it started to loose frames once again.  With about 228GB of data on the disk, capturing errors occured.  I am returning the drive to Best Buy and going to the Apple Store to buy another one, Seagate probably.

UPDATE 2: I finally went to the Apple Store and got a LaCie d2 Quadra 1TB drive.  I definitly see a speed increase due to the 7200rpm spindle speed and so far, capturing is a breeze in FCE.

It all started when I decided to capture my trip footage (5 Mini DV tapes).  I realized that my 300GB drive reserved for video editing was almost full.  A great WD 7200rpm IDE drive that always worked perfectly.

So I decided to go buy a brand new one.  I was looking for a Firewire 800 interface and around 1TB of storage, and 7200rpm (which is a must in video editing).

So I saw the WD My Book Studio Edition 1TB offering at Best Buy, and it seemed to be the perfect choice.  I trust WD (never had problems with their drives in the past 6 8 yeras) and it is specifically built for the mac (the drive is formatted as HFS+ journaled).  But I was not so sure about the spindle speed.  It is no where specified on the box and on their web site.  So I was a bit afraid.  Some places on the net (such as Amazon) say it is a 7200rpm drive.  And WD themselves market the drive as a solution for video editors.  But the WD FAQ say that they only garranty the storage size and throughput and don’t specify the spindle speed.  Scarry!

So I bought the drive.  Here’s what happened when back home.

I connect the drive through the FW 800 adapter and yes, the drive is seen as a HFS+ drive.  So I copy over all my video files from my 300GB drive.  2 -3 hours later, I launch Final Cut Express and proceed with a video capture.  Almost 2 minutes down the road, an error occurs: frame dropped.  This is usually a sign that the storage hardware cannot keep up with the data coming in.

So here are all my attempts at getting this error away:

  1. Restart the capture, just in case it was a transient error.  FAIL
  2. Instead of using the “Now” capture mode, set in/out edit points and capture using the “Clip” mode. FAIL
  3. Restart the mac and attemps a new capture.  FAIL
  4. Change the user preferences so that the dropped frames are ignored during capture.  Capture works but the playback is aweful: freezing, out of sync with the audio.  Totally unacceptable.  FAIL
  5. Use the other FW800 cable that I have. FAIL
  6. Do the capture and store on my old drive. SUCCESS.  At this point, I know the problem is with the new drive and not the DV tape or FCE.
  7. Upgrade the drive firmware to 1.034 and attempt another capture: FAIL
  8. Capture through the USB2 interface instead of FW800.  FAIL

At this point, I was suspecting that the drive inside the enclosure might not be a 7200rpm drive and that would for sure explain the problem.

Before returning the drive to Best Buy, I decided to try something I should have done earlier: reformat the drive using Disk Utility.

Then I tried a capture with the blank new drive: SUCCESS.  Capture works great and the playback if quick and snappy like my old drive.

Alright.  Maybe it now works because the drive is empty.  I copy over my old video editing content (192GB).  2-3 hours later, I try a capture and again, it works great.

At the end of the day, I learned that we should NEVER trust the formatting of a out-of-the-box drive and always reformat it before use.

Hoping this post will help someone else!

Cheers

One of my customers created a simple form in WebCreator Pro, a donation form sending an email to their administrators.  Next, they wanted to tie the form with a payment gateway, Moneris in this case.  This is not a out-of-the-box feature of WebCreator Pro, of course.  Here I come to the rescue.

They built all their site with WebCreator Pro, and they didn’t want to switch to another CMS.  They also wanted to integrate the Moneris payment gateway at the lowest possible cost .  My previous experience was with fully embedded payment solutions, using Active Merchant and Ruby on Rails.  So this was a new challenge for me.

Solution

First, the cheapest way to integrate Moneris is to use their eSelect Plus Hosted Payment Page package.  The form submits the data to one of their web servers, and you then configure the page to your needs.  This solution also supports recurrent transactions, which was needed by the customer. Moneris has a great testing environment, so I was able to fully test my solution.

Next, when submitting data, you have to use a naming convention for the fields, as per Moneris integration guide.  And you also have to make sure the data is well formatted for the fields .

So here I am with an HTML page generated by WebCreator Pro.  This tool does not allow the designer to control how the HTML is generated.  You can include some javascript code, but tying it with elements in the DOM is not that smple.

I decided to go with jQuery (I love jQuery!).  It was just a matter of including a “javascript include” in the page and then all my logic would sit in a .js file that I have full control on it.  I was able to do that in WebCreator Pro by adding a Counter object at the top of the page.

In a nutshell, here’s what my script does after it loads:

  1. When the DOM is ready, modify the form to change the encoding to ISO-8859-1 (required by Moneris to support french accents – by the way, this won’t work in IE).
  2. Add hidden fields for the store ID and key.
  3. Add additional hidden field to comply with the integration guide.  I also have some fields that are specific to the recurrent payment (if selected by the user).
  4. Change the “onclick” event of the submit tag so that it calls one of my functions.
  5. Fill-out some default values.

Then, the script will do some validations and some data manipulations when the user hits the Submit button.  If everything is find, the form will get posted to the Moneris server and the user will then enter her credit information.

This solution of course requires Javascript, but we assume that Javascript is enabled on the browser.  Anyway, most of the WebCreator Pro output requires javascript.

Then it was as simple as deploying my javascript files on the test and production servers.  Fortunately, WebCreator Pro does not wipe out the files when it publishes the site.

Have fun!

Everybody knows that after a while, you loose the ability to scroll down with the mighty mouse.  This is the most used scrolling direction on the mouse.  So if you are in this situation, don’t throw the towel yet.  

Here are the solutions I tried:

  • The one from Apple itself.
  • Some of the ones in here.
  • Cleaning the ball using a cooton swab and rubbing alcohol.  It did the work a few times!
  • Blowing pressured air around the ball.

It worked a couple of times.  But lately, nothing was putting a smile on my face.  The mouse was really getting on my nervers.  I was about to “scrap” the mouse and buy a new one.  But hey, I might as well try to open it and clean it.  Worst case, I will break it and it will still go in the garbage.

So I watch this great video from Julian Schrader and decided on a sick day to just do it.  

First, let’s get the tools.  Second, wash the exterior of the mouse.  We don’t want to contaminate the patient during the operation.

dscn36611

Bad news: I cut my finger while trying to remove the ring with my knife.  So a few days after recovering from the cut, I decided to continue the delicate operation and use a small screw-driver to finish removing the ring.

I damaged the ring a little bit, but who cares! You never see it when the mouse is on a surface.  And once again, I was ready to throw this baby away.

I disconnected the cables, unscrewed the scrolling case, and voila! Look at the dirt inside:

dscn3654

 dscn3655

Now I understand why the mouse was so picky.  Look at the amount of dirt on the right scroll wheel (the one used while scrolling down).  Mystery solved!

Now the easy stuff: cleaning the parts with a cotton swab and rubbing alcohol.  A clean wheel will look like this:

dscn3656

You can also take all four wheel and put them side by side.  They are magnetized, so they love each other and stay together.  Cleaning with the cotton is a lot easier.

dscn3658

Now before screwing the scrolling case back into the mouse, make sure the ball scrolls properly.  Gently put your finger on the ball, scroll and watch the wheels to see if they really scroll.  The scroll down function was still not going as smooth as I wanted.  So I opened the scrolling case again and found the problem:  the magnetic wheels do not have to touch the metal plates.  Otherwise, it puts a pressured on the wheel and you have to apply a lot of pressure on the ball to make it scroll.

dscn3655b

Finally, I reassembled the mouse, anxiously wondering if the scrolling experience will have improved.

Once in a while, blow some pressured air all over the place to make sure there nothing left, especially before putting back all the pieces together.

Now the ring was originally glued to the mouse casing. Instead of using some crazy glue and because I guess I’ll hae to repeat the operation in the future, I decided to use rubber cement glue.  You put glue on both sides, way for it to dry and then put the ring back.  The remaining glue can be removed with the fingers.

 

Overall, this was a fairly simple operation.  The worst steps were:

  • Removing the ring.  I broke it a bit while forcing with my screw-driver.  So do it very carefully.
  • Putting back the cables in their sockets

Now my mouse is like new.  What a great feeling of scrolling down and see the page going up!

UPDATE: This video seems to be a bit better, especially for the tool he’s crafting for removing the ring.

After adding simply_versioned support in a model that is using attachment_fu with S3 storage, I was getting this strange error the second time my versions association was used in my application:

NoMethodError (undefined method `quoted_table_name' for "0.5.1":String)

After a few hours, I finally figured out that this was caused by the aws/s3 setting its Version to “0.5.1″ (in a module).  That module gets included by attachment_fu.  The simply_versioned plugin uses a Version model.  So I don’t know it this a bug with attachment_fu or Rails, but here’s what I did to fix the problem.

  1. Rename the Version model to DataVersion
  2. add “set_table_name ‘versions’” in the DataVersion model if you don’t want to rename the table in the database
  3. In the simply_versioned.rb file, search for the “has_many” instruction and add :class_name => ‘DataVersion’

And voilà.  Everything should work fine now.

Older Posts »