Here’s a very simple way to validate an email address using regex.
Validate Email Address using Regular Expressions
Rails and Paypal Certificate Expiration
On railscasts.com episodes #141 to #143 Ryan went through how to setup online credit card payments via Paypal and IPN. Worked like a treat after a few late nights and some modifications.
If several years down the track you find the public key you provided Paypal has expired, do the following.
1. Generate a new public certificate
Run the following command wherever your current certificates are held. Most likely in RAILS_ROOT/certs. Change 365 to how many days you want the certificate to be valid for.
2. Upload new public certificate to Paypal
Login to your Paypal Account and go to the following menus: My Account -> Profile -> My selling tools -> Encrypted payment settings. The last option will be at the bottom of the page. This will take you to a Website Payment Certificates page.
You should see your old expired certificate here in a list. Click the Add button. This will take you to a page where you will need to upload the certificate you generated in step 1. Remember, upload the app_cert.pem file!
You should go back to the Website Payment Certificates page and your new Public Certificate will be listed. Copy the Cert ID for the newly uploaded certificate. We will use this in step 3.
3. Modify your config/paypal.yml file
Open your RAILS_ROOT/config/paypal.yml file and find the paypal_cert_id entry under production. Replace it with the Cert ID you copied in step 2.
Here is an example from paypal.yml:
paypal_email: example@blahblah.com
paypal_secret: blahblahblah
paypal_cert_id: [replace this]
paypal_url: https://www.paypal.com/cgi-bin/webscr
paypal_currency: AUD
4. Restart rails
You will need to restart rails so the modifications made in step 3 will be loaded.
The following command will restart Passenger:
Extra notes
If you are running capistrano to deploy your app into production make sure you modify the correct files so that subsequent deployments use the correct app_certs.pem and paypal.yml files. Typically you will want to modify the files in your shared/certs and shared/config directories as the latest production release will have symbolic links pointing to them.
Rails 3 and Bundler
Useful Bundler commands.
bundle install # reads gem list from Gemfile and installs them
bundle check # check gem list from Gemfile and sees if any aren't installed yet
bundle help # lists available commands
bundle install --without=test # like install but ignores test env gems
bundle lock # freezes gems to current versions
bundle install --relock # unlock gems, update and lock again
bundle pack # installs gems locally to vendor/cache
Rails RESTful Routes
| HTTP request |
URL | Action | Named Route | Purpose |
|---|---|---|---|---|
| GET | /users | index | users_path | page to list all users |
| GET | /users/1 | show | user_path(1) | page to show user with id 1 |
| GET | /users/new | new | new_user_path | page to make a new user (signup) |
| POST | /users | create | users_path | create a new user |
| GET | /users/1/edit | edit | edit_user_path(1) | page to edit user with id 1 |
| PUT | /users/1 | update | user_path(1) | update user with id 1 |
| DELETE | /users/1 | destroy | user_path(1) | delete user with id 1 |
Syntax Highlighting for WordPress
I need a syntax highlighter if I am going to be placing code up on my blog. I went with CodeColorer after I noticed it supported a Railscasts theme. I’ve been reading Railscasts since the day I first started learning about RoR and it truly is awesome!
def self.up
create_table :users do |t|
t.string :name
t.string :email
t.timestamps
end
end
def self.down
drop_table :users
end
end
VirtualBox 4.1.6 Error – VERR_LDR_MISMATCH_NATIVE
So I decided to update my Ubuntu virtual machine from 9.1 to 10.04. After the upgrade of my Ubuntu system in my virtual machine I couldn’t get fullscreen mode to work so I also upgraded from an old version of VirtualBox to version 4.1.6.
Then when I went to start my Virtual Machines I found they were all bricked with the following error message appearing in a popup box:
Result Code: E_FAIL (0x80004005)
Component: Console
Interface: IConsole {1968b7d3-e3bf-4ceb-99e0-cb7c913317bb}
Aaargh! A quick search on Google and I found the following solution was to delete the directory C:\USERS\<username>\AppData\Local\VirtualStore\Program Files\Oracle and all it’s subdirectories. After that my Virtual Boxes would start!
Moodle, SCORM and Articulate Studio 09
I’ve been to several Moodle courses recently and whilst they have been enjoyable there doesn’t seem to be much coverage on using Moodle with SCORM. It’s mostly been about using Moodle as a CMS to organise some type of structure for placing your course content ‘online’. Now I have nothing against that but it doesn’t really seem like true elearning to me.
Recently I’ve been getting into scenario based elearning especially the kind that Cathy Moore advocates (here is her brilliant ‘How to save the world with elearning scenarios’ presentation on slideshare).
We use Articulate Studio 09 as our rapid elearning authoring tool here at Australian Food Training Centre. It is a brilliant package which I highly recommend and I’ve pointed to some good starting tutorials on my eLearning page. It allows you to easily create the kind of scenarios that Cathy has been talking about. This is fantastic and solves one part of the equation but the whole Moodle and SCORM.
So over the next few posts I’m going to dedicate some time to explaining how you can get Moodle and SCORM + Articulate Studio 09 (MaSAS) to play with each other.

