One more nice and better way to "public share" your local application

Few months back we had a nice pagekite.net - fast and reliable localhost tunneling solution post by Swapnil.I am extending it further. Pagekite and localtunnel both the solutions are really good. However both has some drawback or limitations. e.g. For Pagekite you should have an account on Pagekite site and that login will last only upto 30 days or so. However most of the time you do not need Public sharing of the app all the time For localtunnel the only drawback is change of url every time you start it. However in practical scenarios some times

Suggestions On Redis, Backing-Up Redis And Setting up production environment for redis

Redis installation at local is one of the easiest things to do. However, There are some gotchas involved when we are trying to use redis. Running redis-server without config(Default Config File will be picked). When we run redis-server without config, then it creates a dump.rb(A physical file to store all data related to redis) at the folder from which we are starting the redis. We normally, don't realize the impact of this issue as we start the redis server at the same project folder every-time. However, If we start the redis from the some other folder, then

jquery ketchup-plugin for Client-side form-validation

jquery ketchup-plugin for Client-side form-validation: There are many jquery plugins available for client-side form validation (to validate form before actually submitting it). jquery ketchup-plugin is one of them. Github: https://github.com/mustardamus/ketchup-plugin Demo: http://demos.usejquery.com/ketchup-plugin/ Validations provided by plugin: https://github.com/mustardamus/ketchup-plugin/blob/master/jquery.ketchup.validations.js Steps: include css file in your application.css file *= require jquery.ketchup include js file in your application.js file //= require jquery.ketchup.all.min Form: = simple_form_for(@user, :html => {:class => 'ket-validation'}) do |f| = f.input :first_name, input_html: { class: "required_field "} = f.

Rails Store - A solution to store multiple value in single column.

What is ActiveRecord::Store? Store provides a simple means of accessing and storing key/value pairs related to a model. Store gives you a thin wrapper around serialize for the purpose of storing hashes in a single column. In simple words, it is used for storing mutiple columns under a single column. Its serailized/deserialized to save and load the data for easy access. Example You have a Music application, you want to cache the last volume adjustment for the user. So that when he returns back, same volume level is applied, similarly other volume related settings. Now you can

Parsing Yaml Files in Javascript.

Why we need YAML parser. As long as we are working in rails we will hardly face a situation, where we have to parse the YAML files in javascript.However when we are planning to work on node.js OR tideSDK where javascript is the heart of everything, then in that case we need something to parse the configs and then writing to configs if necessary. There are many parser available to read the YAML. But there are very few which does the reverse good. I found just two plugins like that. One plugin was bit confusing and it had

Reload or Add routes at runtime in Rails 3

In one of our eCommerce app, we needed SEO friendly Menu urls like /brandy/cognac. For this, we added a generic route /:parent/:child/:grandchild at the bottom of config/routes.rb. With this approach, there was an issue with invalid urls like /this/is/wrong being redirected to specified controller action. To fix this, we used Menu names to generate specific urls. But the routes would become invalid if Admin changes the menu name. So we needed a way to reload routes once the menu is updated. I found a hack mentioned in [this blog(Blog)][1] that allow

Faster Specs with FixtureBuilder

What is [fixture_builder][1] ? Fixture Builder creates fixtures based on your definitions of [FactoryGirl][2] Why fixture_builder ? In projects with huge test suite, its possible that the creation of AR objects hinders the test performance. So to gain performance, we can avoid the redundant database transaction by building subsequent fixtures. Examples https://github.com/rdy/fixture_builder#example It gives tremendous boost to your test execution time. For us the statistics for 550 test cases were : Before fixture_builder ~ 2.5 hours After fixture_builder ~ 19.37 minutes Note : This should be backed up by proper [DatabaseCleaner][3]

Rails 4 has asset digest issues

For those upgrading to OR using Rails 4 Please have a look at the github thread https://github.com/rails/sprockets-rails/issues/49 Proposed solution : https://github.com/alexspeller/non-stupid-digest-assets OR https://github.com/rails/sprockets-rails/issues/49#issuecomment-25946196

Avoid rails helper times_ago_in_words()

Let's say we have 100 records in lessons table then %td.last_modified= times_ago_in_words(lesson.updated_at) server calculate the time ago for each record for each request, it wastes a lot of time on server side. If we replace above code by %td.last_modified"= lesson.updated_at.to_s and load jquery plugin <script src="jquery.timeago.js" type="text/javascript"></script> then in JavaScript $("td.last_modified").timeago() thats it. Then the javascript will calculate the time ago on client side after loading

Alternative way to highlight the current active page

This post is very much similar to the post of Abhijit. [Highlight the active page (Highight the active page)][1] by Abhijit. This would work very well if we have simpler routes, if we have complex routes(Modular routes) in our app where we have similar urls with same action then we need to enhance this approach. For e.g There are three links on the same page as follows. 'web/dashboard' 'mweb/dashboard' 'mapp/dashboard' All these are pointing to same action. i.e Dashboard. So selecting active tab based on action name will fail here and will highlight