Category: Ruby On Rails

Ruby on Rails, often shortened to Rails or RoR, is an open source web application framework for the Ruby programming language.

How to read large XML files efficiently using PHP?

Recently I was faced problem of parsing large XML file using PHP. While parsing small files are no problem and all its quickly parsed, an attempt to parse larger files often causes time-out or Internal Sever Error. We will not able to use DOM or SimpleXML extension to parse the large XML documents in PHP. …

Continue reading

Permanent link to this article: https://blog.openshell.in/2014/09/how-to-read-large-xml-files-efficiently-using-php/

MySQL zerofill and lpad – Shape digits in DB

I’m working with an application to have the item code. Item code column is set as an INT(5) but not all the item code values are 5 digits. So I need to round off the item code based on 5-digits. If the item code is 199, it should be display as 00199. How to make …

Continue reading

Permanent link to this article: https://blog.openshell.in/2014/09/mysql-zerofill-and-lpad-shape-digits-in-db/

Best way to order the best matching records in MySQL

If we are searching a word (string) in the mysql table, usually we will use the below method: [sql] SELECT * FROM user WHERE name LIKE ‘%searchstring%’ ORDER BY name ASC; [/sql] If you search like this, It will order the result set based on the ASC of name. It will not order the result …

Continue reading

Permanent link to this article: https://blog.openshell.in/2014/08/best-way-to-order-the-best-matching-records-in-mysql/

How to use MySQL for case sensitive string comparison

By default MYSQL character set and collation are latin1 and latin1_swedish_ci, so non-binary string comparisons are case insensitive. This means that if you search with col_name LIKE ‘a%’, you get all column values that start with A or a. To make this search as case sensitive, make sure that one of the operands has a …

Continue reading

Permanent link to this article: https://blog.openshell.in/2014/07/how-to-use-mysql-for-case-sensitive-string-comparison/

How to use Jsonp method in JQuery

JSONP is JQuery(JavaScript) method used to request data from a server in a different domain, something prohibited by typical web browsers because of the same-origin policy. JSONP takes advantage of the fact that browsers do not enforce the same-origin policy on<script> tags. JSONP is a viable solution for cross-domain Ajax. JSONP does not work with …

Continue reading

Permanent link to this article: https://blog.openshell.in/2014/06/how-to-use-jsonp-method-in-jquery/

Rails 3 GEM to handling where the error has occurred

It’s Better Errors GEM. It will handle the error and we can see exactly where the error has occurred in development machine. GITHUB : https://github.com/charliesome/better_errors Steps to configure in our rails3 application 1.  Install the  gem install airbrake -v ‘3.1.8’ 2. In your Gemfile add group :development do gem “better_errors” end If you would like …

Continue reading

Permanent link to this article: https://blog.openshell.in/2014/03/rails-3-better-errors-gem-handling-where-the-error-has-occurred/

Use Number() instead of parseInt() in javascript

Recently I came across the issue in converting string to integer in Javascript(JS). I was used parseInt() method to convert string value into integer value. unfortunately, I was faced issue in chrome browser but all other browsers like firefox, ie and safari are worked fine. Its too hard time for me to find out the …

Continue reading

Permanent link to this article: https://blog.openshell.in/2014/01/use-number-instead-of-parseint-in-javascript/

Dynamically create form in javascript on fly

To create a form dynamically using JavaScript on fly of the webpage. This which helps to create form and input controls dynamically. [javascript] /* To create form with javascript */ var form = document.createElement("form"); form.setAttribute(‘method’,"post"); // form method form.setAttribute(‘action’,"test.php"); // form action url form.setAttribute(‘name’,"frmName"); // form name form.setAttribute(‘id’,"frmId"); // form ID form.setAttribute(‘target’,"_blank"); // form target …

Continue reading

Permanent link to this article: https://blog.openshell.in/2013/12/dynamically-create-form-in-javascript-on-fly/

How to use serialized object in Active Record using Rails?

Serializing Object Will help us to store multiple column values in single Database column and even making processing using that column simple. It helps to extended the table without adding new column in table. Because we can store multiple column values in single column as Hash value. So, It reduce the difficulty of retriving and …

Continue reading

Permanent link to this article: https://blog.openshell.in/2013/11/how-to-use-serialized-object-in-active-record-using-rails/

Find number of working days between two dates in Mysql

This which helps to find number of working days between two dates in Mysql. There is no specific or inbuilt function in mysql, For that we need to use the SQL query as below. [sql] SELECT 5 * ((DATEDIFF(@end_date, @start_date) ) DIV 7) + MID(‘0123455501234445012333450122234501101234000123450’, 7 * WEEKDAY(@start_date) + WEEKDAY(@end_date) + 1, 1) [/sql] For …

Continue reading

Permanent link to this article: https://blog.openshell.in/2013/08/find-number-of-working-days-between-two-dates-in-mysql/