Welcome!

Code snippets and other useful things.
Rails and Paypal Certificate Expiration

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.

RAILS_ROOT/certs$ openssl req -new -key app_key.pem -x509 -days 365 -out app_cert.pem

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:

production:
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:

RAILS_ROOT$ touch tmp/restart.txt

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

Rails 3 and Bundler

Useful Bundler commands.

gem install bundler # installs bundler
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
Install Google Chrome on Ubuntu 10.04

Install Google Chrome on Ubuntu 10.04

Rails RESTful Routes

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
Rubular – Ruby Regex Editor

Rubular – Ruby Regex Editor

The 4-Hour Body

The 4-Hour Body

Syntax Highlighting for WordPress

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!

class CreateUsers < ActiveRecord::Migration
  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

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

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.

MoWeS – Moodle on your USB key

MoWeS – Moodle on your USB key

Want to have your own version of Moodle where you have full administration rights?  Want to be able to install the full apache/mysql/php/moodle stack with a few simple clicks of the mouse?  Want to be able to take your copy of Moodle and run it at work, at home, friends house, relatives etc?  Well then you need to get a copy of MoWeS!  I found out about this awesome program from Nick Lambert at e-Dayz09 last week.

What is it?

MoWeS Portable uses the apache/mysql/php stack and you can install to any media device including removable hard disks, USB keys, flash drives or memory sticks.  This gives you a fully functional webserver but the real exciting part is that there is also a heap of application software prepackaged for you to download including Moodle, WordPress, Drupal, Joomla, Mambo, MediaWiki, OS Commerce, SugarCRM, Xoops and a raft of other applications.

Benefits

Whenever you are learning a new computer system it is always great if you can have a copy of it with admin rights and the ability to play away and not worry about stuffing anything up or affecting other users.  This is where MoWeS is great, you have your own webserver with whatever software you want on your USB key!  It’s your webserver, you can do what you want with it and if you stuff something up it only affects you so all you do is delete it and reinstall it again! You see it doesn’t install anything to your actual computer, it’s all contained on the USB key so your computer won’t get clogged up with junk.

Now you may already have access to say Moodle and in fact my web hosting account comes with the option to install Moodle which I have done.  The problem I’ve found is that it’s too slow running from my web hosting account which I think is due to the fact that my web hosting is in the US.  Having MoWeS + Moodle on my USB key is blindingly quick which for me is a God send.

In my next post I’ll go through how to install MoWeS but in the mean time check out the MoWeS Portable website for all the features.