Archive for July, 2007

How to use SyntaxHighlighter

Posted in SyntaxHighlighter, ror, Rails, Ruby on Rails on July 23rd, 2007 by Satish Chauhan – Be the first to comment

SyntaxHighlighter:

SyntaxHighlighter is a source code syntax highlighting plugin to help a developer/coder to post code snippets online with ease and and without having to worry about applying format. It is a free JavaScript tool for source code Syntex highlighting , It doesn’t care what you have on your server.

The idea behind SyntaxHighlighter is to allow insertion of colored code snippets on a web page without relying on any server side scripts.

WP-dp.SyntaxHighlighter supported languages:

  • C#
  • CSS
  • C++
  • VB & VB.NET
  • Delphi, Pascal
  • Java
  • JavaScript
  • PHP
  • Python
  • Ruby
  • SQL
  • XML, HTML, XSLT and any other XML style code

Click Here to download SyntaxHighlighter

http://syntaxhighlighter.googlecode.com/files/SyntaxHighlighter_1.5.0.zip

How to use SyntaxHighlighter

Place your code on the page and surround it with <pre> tag. Set name attribute to code and class attribute to one of the language aliases you wish to use.

<div class=”dp-highlighter> </div>

<pre name=”code” class=”ruby” style=”display: none;>
… some code here …
</pre>

An alternative to <pre> is to use <textarea> tag.

<textarea name=”code” class=”ruby”>
… some code here …
</textarea>

And You will get an output like

How to import CSV file in rails

Posted in CSV, ror, Rails, Ruby on Rails on July 18th, 2007 by Satish Chauhan – Be the first to comment

How to import CSV file in rails?

The CSV text-file format is a common choice for both import and export when performing data migrations. What if you want to import CSV files within a Rails application?

Here is the code that allow you to upload CSV data onto the MySQL database from the web interface
This code save data direct to database without saving it to temp file

Controller:


View:
your view will look like

Verify Email address Format

Posted in Regexp, ror, Rails on July 3rd, 2007 by Satish Chauhan – Be the first to comment

Useful expressions for email address validation

Matches a limited version of the RFC 2822 addr-spec form.

satish chauhan’s blog