Code Snippets

Use JavaScript To Require Data To Be Entered Into A Form Field Before It Can Be Submitted

I needed a simple way to require data in a form field before it could be submitted. There are chunks of JavaScript code all of the Internet that allow you to do this easily so I selected one and added it to my form with ease. One small issue I had was it required that the name attribute be modified for it to work which caused an issue with the application I was adding it to. The issue was the name attribute was modified thus it would not save the data to the proper database table column. Below I explain how to add this bit of JavaScript to your form and modify your form for it to function properly.

Code Snippets

MySQL Ruby Gem: `require’: no such file to load — mysql (LoadError)

I am starting to learn ruby and am working on a test script to import some data into a MySQL database. I am using the below code found on kitebird.com to first get the MySQL connection from Ruby working. The code was producing an error which I figured might be because I installed the MySQL Ruby gem instead of installing the MySQL Ruby module from source.

The below code attempts to connect to the MySQL server to return the MySQL server version.

Technology Insights

Setting up BackgrounDrb

I decided to use BackgrounDrb 0.2.1 to launch a periodic task that would run every 15 seconds.Warning: After going through the hassle of setting up BackgrounDrb, I found out that it isn’t even supported in Windows (my dev environment)! See step 8. So, these instructions haven’t been fully tested yet on a *.nix environment. Good…