View formatted table columns using table_print gem

table_print Gem It's an efficient way to view a list of structured data, making it easy to scan and compare across large swaths of records. It even lets you nest other tables of related objects, contextualizing data across tables. It’s incredibly flexible, yet simple, making it easy to see exactly the data you care about. INSTALLATION: To install the gem: Add the following to your gemfile- gem "table_print", "~> 1.0.0" Then run: $ bundle install USAGE: Go to rails console: $ rails c Eg. 1) To view the entire table: tp Size.all Will give the output: ID

Attaching images using Attachinary and Cloudinary

A] Cloudinary: Cloudinary is a cloud service that offers a solution to a web application's entire image management pipeline. It is used to easily upload images to the cloud. It automatically performs smart image resizing, cropping and conversion without installing any complex software. Also, integration of Facebook or Twitter profile image extraction in a snap,that too in any dimension and style to match your website’s graphics requirements. Add following line to your Gemfile: gem 'cloudinary' Add following line to config/cloudinary.yml development: api_key: //enter api key api_secret: //enter api secret cloud_name: //enter cloud name

Recaptcha setup and usage with devise

recaptcha is a gem that uses google's CAPTCHA service. A CAPTCHA is a program that can tell whether its user is a human or a computer. To Setup recaptcha on local machine we need to add the gem, gem "recaptcha", :require => "recaptcha/rails" then we need to obtain private and public key by registering to this url http://www.google.com/recaptcha/whyrecaptcha While registration we can choose if we need public and private keys which work on particular domain or we can choose to use it on any domain. Once we have the public and private key we can

Solr query language and testing search results using "Solr Admin" page

Recently we had a bug in one of our app where search was not able to find anything based on sub keywords or sub text. Lets say we have an article that has keyword "dedicated" in subject or body or in tags. Now if we try to search using keywords say | cat | cate | ted | dedi | dicat | dedi | then outcome was zero search results. This issue was due to the way indexing was done along with missing query configuration in Solr. We fixed the indexing and seaching configuration in solr/conf/schema.xml file. We added/edited following code

List of frequently used Linux - Ubuntu console commands

Following is an handy list of frequently used Linux (Ubuntu flavour) console commands Find Files find . -name '*.cnf' find . -name 'hello.workd' The dot here represents all files and folders in current path Mysql DUMP - Import and Export Export mysqldump -u username -p database_name > file_name_to_save.sql Import mysql -u username -p database_name Install LAMP on Ubuntu sudo apt-get install tasksel sudo tasksel sudo tasksel install lamp-server Install Apache2 on Ubuntu sudo apt-get update sudo apt-get install apache2 The /var/www path is the document root for the apache web apps. SCP - File

Monitor Form Changes

All of us have e-forms in our apps, it is an effective tool for gathering information of and from the users. A user fills the e-form and saves the same. Many-a-times, we need to monitor if the user has modified the form contents after once saving the form. Found a plugin that monitors form changes. Add the following code to .js file: (function ($) { $.fn.watchChanges = function () { return this.each(function () { $.data(this, 'formHash', $(this).serialize()); }); }; $.fn.hasChanged = function () { var hasChanged = true; this.each(function () { var formHash = $.data(this, 'formHash'); if (formHash == $(this).serialize()) { hasChanged = false; return true; } }); return hasChanged; }; }).call(

Method / Process to export active record data to excel file, save xls file on S3 and provide download xls feature

In one of our web application, we had a specific requirement wherein the client wanted the data from the app into a specific xls format. Thus we needed to export data from our app in this custom format and save the xls file on S3. Our app will then show a link to "Download" in ActiveAdmin UI clicking which it will start downloading this xls file from S3 on clients local PC. We have broken down the process into numerous steps, hope this will be helpful. The process goes as follows: The data from the app is exported

Stamp gem for Human friendly date and time format

[Stamp Gem(Stamp Gem)][1] Stamp gem is the best gem for converting format of Dates and Times in Human friendly formats. Its very easy to use in our rails application. We can use this gem as: run: gem install stamp or inlude this line in gem file gem 'stamp' then run: bundle install. Example: Suppose, I have a date = 2014-01-15 18:19:07 +0530 then we can convert this date into humans friendly date format like date.stamp('1-Jan-2000') => '15-Jan-2014' date.stamp('1st Jan') => '15th Jan' date.stamp('Jan 1, 2000') => 'Jan 15, 2014' date.stamp(

Zapier

1) What is Zapier ? Zapier is an easiest way to do automation as their tagline says “superpower to get your work done”. Its a Web-App which allows different web apps to communicate amongst themselves very easily. This communication between two apps, is called a zap, associate a pair(trigger and action) with each zap. Example: Say you receive an email from a very important source, and want to notified quickly and create an event/task in your calendar to perform action related to email. This entire task can be configured in Zapier to track a particular email, send you a

Benchmarking in Rails console - Know performance of a code snippet

Lets say we need to benchmark and evaluate the performance of code snippet. This is how we can easily do on Rails console using "Benchmark.ms" require 'benchmark' 1.9.3-p392 :001 > Benchmark.measure do 1.9.3-p392 :002 > "john mark McMillan".split(" ").collect{|word|word[0] = word[0].upcase; word}.join(" ") 1.9.3-p392 :003?> end => #<Benchmark::Tms:0x00007ff6cd8face8 @label="", @real=1.600012183189392e-05, @cstime=0.0, @cutime=0.0, @stime=2.9999999999960614e-06, @utime=1.8999999999991246e-05, @total=2.1999999999987307e-05 1.9.3-p392 :004 > Benchmark.