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

Init Script To Run Django FastCGI Threaded On A TCP Port

I have been messing around with Django over the past week and experimenting with various settings. I first ran Django using mod_ptyhon from Apache but the results were unimpressive. Apache served the Django project’s pages extremely slow using the Apache mod_python module. After some reading I decided to give the Apache mod_fastcgi module a try to see if the results were any better. I was definitely happier with the web page load time so I then decided to experiment with various FastCGI settings.

Code Snippets

Create A Toggle In .irbrc To Toggle IRB Debug Output On or Off

The Interactive Ruby Shell, or irb, is a great tool to use when debugging Ruby code. You can launch it from a shell window and quickly determine where errors in your Ruby code. Obviously irb is not always the best tool to use when debugging a large code base however for quick hints to where errors are in your Ruby code irb will save the day. One thing I noticed was sometimes when creating arrays irb would output the entire array even if you have not called for that output. So I was thinking it would be nice to be able to toggle the verbose output of arrays on or off during troubleshooting. The verbose output of irb is typically very useful so this toggle should only be used in some scenarios. Below is an explanation of how to create a toggle to turn the irb context echo on or off.

Code Snippets

Updated Bash Script To Provide Read Only Postgres Database Table Access

I wrote an article a couple weeks ago regarding a shell script to run that would provide a postgres user read only access to every table in a specific database. Tonight I was updating a over a dozen databases and needed to provide read only access to all of them to a specific user so I decided to update the bash script from a couple of weeks ago to take a couple variables from the shell so you could specify database and user. The new script along with instructions on how to use it are below.

Code Snippets

Add SEO Friendly Page Titles To The WP-Forum WordPress Plugin

Awhile back I found some code that described how to make the page titles for the WP-Forum WordPress plugin SEO friendly. By default WP-Forum includes the site name and title of the forum itself for every page generated by the forum. To generate more web traffic for your site it will be beneficial to modify the page titles so they include post title and/or forum group name. Follow the directions below to dynamically generate new page titles for each forum post.