Main Super Tables Resources Puzzles
  Search:
Most Popular Other Sites

Number Validation with Javascript Regular Expressions

Posted on February 22, 2008 04:59:21 PM --- 3818 Views --- 5 Comments

Rather than rewrite what is already on many websites such as this one, I'm simply going to post some regular expressions that you may find useful for things such as form validation and file parsing.

  • Positive Integer Values: /^(0|[1-9][0-9]*)$/
  • Positive Decimal Values: /(^(0?|[1-9][0-9]*)\.(0*[1-9][0-9]*)$)|(^[1-9]+[0-9]*\.0+$)|(^0\.0+$)/
  • Positive Integer and Decimal Values: /(^(0|[1-9][0-9]*)$)|((^(0?|[1-9][0-9]*)\.(0*[1-9][0-9]*)$)|(^[1-9]+[0-9]*\.0+$)|(^0\.0+$))/
  • Signed Integer and Decimal Values: /(^[+]?0(\.0+)?$)|(^([-+]?[1-9][0-9]*)$)|(^([-+]?((0?|[1-9][0-9]*)\.(0*[1-9][0-9]*)))$)|(^[-+]?[1-9]+[0-9]*\.0+$)/
  • Signed Floating Point Numbers: /^([-+]?[0-9]*\.?[0-9]+)$/   --Source: http://www.regular-expressions.info/floatingpoint.html

You may notice that some of these are really long. This is because they are rather strict when matching valid values. To see why by example, select a tab in the demo below.

Read more...

Add Powerful Charts and Graphs to Your Ruby on Rails App Using ZiYa

Posted on December 09, 2007 01:08:39 PM --- 1260 Views --- 0 Comments

If you're looking to add powerful, dynamic, customizable charts and graphs to your Ruby on Rails app, consider using the ZiYa plugin for XML/SWF Charts. It's quite easy to install and best of all it's free. All it requires is a simple script/plugin install from Rubyforge followed by a couple of require/include lines in your controller and that's it.

Some of the nicest features of the ZiYa plugin are support for dynamic data (on the fly rendering) and fully customizable look and feel skins that you can create in xml. For the app I am currently using these graphs on, I created session variables that the chart action (ie rails action) would read in and from that create a graph with a customizable skin I had made to fit the look and feel of my site. All in all, it took less than a few hours for me to figure everything out and have a page load with exactly what I wanted. Thanks in part to ZiYa's website which showcases a training page that has a dynamic xml stylesheet that you can edit and see exactly how your edits change the graph's look. If I wanted to add a graph nowadays, it would take almost no time at all. And this isn't because I'm some sort of genius, ZiYa just makes it that simple!

Read more...

7 Great Tools for New Ruby on Rails Developers

Posted on December 04, 2007 09:33:14 PM --- 923 Views --- 2 Comments

Whether you're new to the Rails development community or are a seasoned veteran, here's a list of seven great tools any developer should have in their arsenal.

1. Web Developer plugin for Firefox by Chris Pederick

Simply put, a must have. This tool gives you the ability to view the generated source code on a rendered page, it allows you to disable CSS styling, view the document size, clear session and cookie data (great when working with that kind of stuff), and a ton more. You can download it at Firefox's add-ons page here.

2. SEO for Firefox plugin by Aaron Wall

This is a great tool for search engine optimizers which these days every successful web designer must become. This little plugin lets you view Google's Pagerank rating on any website you desire. It also relays for you a bunch of other nifty details such as the age of a site, an estimated inbound link count, a site's Alexa / Compete.com rank, and more. Grab it here at Aaron Wall's SEO site.

3. Multiple IE Installer

Another great tool, this program lets you install Internet Explorer 3.0, 4.01, 5.01, 5.5, and 6.0 all on the same pc! Though these days 5.5 and down are pretty much obsolete, it nevertheless allows you to have both IE6 and IE7 installed and running at once for all your testing needs. Multiple IE can be downloaded on TredoSoft's website for free.

Read more...

Turn Your Ruby on Rails App into a Standalone, Distributable .EXE File

Posted on December 03, 2007 06:25:29 PM --- 4132 Views --- 5 Comments

Ever wondered whether you could turn that Ruby on Rails app you wrote into a executable program? Well, wonder no more!

Using SQLite and only a couple of Ruby scripts, turning any Rails app into a standalone executable file that can be installed on any machine without any extra software is quite painless. Here's everything you'll need to get your app packaged up for all those poor folks without Rails:

After a bit of fiddling, I was able to get an app of my own into a packaged executable file. My one concern at the time was keeping the SQLite database from resetting itself back to its original state. This is a concern that Erik lays out in his tutorial and is now most likely a moot point. However, at the time of trying this out for myself (back in February) I remembered having some trouble. Below is the logic and code I used inside of init.rb to get by this issue.

Read more...