Table Print on Rails Console

TablePrint shows objects in nicely formatted columns for easy reading. 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

Install as a standalone gem

$ gem install table_print

Or install within rails In your Gemfile:

gem "table_print"

$ bundle install

Usage

Outside rails $ irb

> require...

Read complete blog post

In Rails 5 Active Record provide two finder methods to specify JOIN on associated tables,

 `joins`
 `left_outer_joins`

Suppose in our application we have Article and Comment. Here comments belong to an article, while article have many comments. Now if we want to show list of all articles along with number of comments, we need join to Article and Comment by left_outer_join.

In rails 4.x, Active Record does not have support for outer joins. So we need to add SQL for left outer...

Read complete blog post

API testing -

A set of functions and procedures that allow the creation of applications which access the features or data of an operating system, application, or other service.

What is an API ?

API is an acronym for Application Programming Interface. It enables communication and data exchange between two separate software systems. A software system implementing an API contains functions/sub-routines which can be executed by another software system.

What is an API testing ?

The API Testing is...

Read complete blog post

Dependency Injection

One of the most important features of the MVC design pattern is that it enables separation of concerns. Hence you can make your application’s components independent as much as possible. This is known as loose coupling, and it makes testing and maintenance of our application easier. Using Dependency Injection you can make you application’s components more loosely coupled.

Dependency Injection(DI) is a software design pattern that allow us to develop loosely coupled code....

Read complete blog post

Raising our Emotional Quotient

We all have different personalities, different wants and needs, and different ways of showing our emotions. Navigating through this takes tact and cleverness – especially if we hope to succeed in life. This is where Emotional Quotient (EQ) or Emotional Intelligence (EI) becomes important.

EI is the ability to recognize your emotions, understand, and realize how your emotions affect people around us. It also involves our perception of others: when we understand...

Read complete blog post

autolink-js is a small (about half a kilobyte), simple, and tested JavaScript tool that takes a string of text, finds URLs within it, and hyperlinks them.

autolink-js adds an autoLink() method to JavaScript's String prototype, so you can use it on any JavaScript string. Take a look at the tests, but essentially, after including either autolink.js or autolink-min.js to your page, it works like this:

Input :

"This is a link to Google http://google.com".autoLink()

Output :

"This is a...

Read complete blog post

While development, a software application is divided into different logical or functional modules for better management. When each module is developed, it is also tested for functionality known as Unit testing. Once all modules are developed and they are integrated and Integration testing is carried out to discover the issues which arise as different modules are interacting with each other. Generally speaking, this phase is also called the System Integration Testing.

There are several kinds...

Read complete blog post

As we all know "Every program needs a memory and unfortunately which is finite in terms of its availability".....:)

Software must cope with memory usage, and there are two ways to manage it.

  • Manually
  • Automatically

Manual management are more prone to errors especially with exceptions and in asynchronous code. This is why modern managed environments (.NET, Java, Erlang, and many more) implement automatic memory management with garbage collection.

Lets see what is Garbage Collection in C#...

Read complete blog post

Recently I was looking at various ways to create a constants in Elixir. I come from ruby background, where it is very easy to create and think of constant. You can create constant by assigning a value to constant name. Constant name should begin with capital letter in ruby. Concept of constant is bit twisted in ruby as we can reassign constant to different value.

 I_AM_CONSTANT = "though i can be reassigned :)"

Ohh! Just remembered this is a post about Elixir and not Ruby. Being in...

Read complete blog post

It was normal Monday like every week. I got my laptop and pressed the Power button then I remembered that I had not Suspended(Hibernated) my machine but instead had shut it down last Friday to make sure the memory is not occupied and system runs faster .

Now the problem with shutting down is, I have to start eight different servers to get my Crossroad's apps up and running. Just for this reason ,I refrained from Shutting Down my machine every day and instead chose to Suspend which would save...

Read complete blog post

Many times App's rate and reviews decides app's success. Reviews by user's are important part of app and decides what are good things about our app and what improvements are needed.

Now a days its common to provide Rate & Review button or link that will redirect to app store or play store.

If we have cordova app then we can simply do it in following way using js. We can identify whether device is android or ios and accordingly open it in window.

$('#rate-app').on('click', function(e) {...

Read complete blog post

There may be times when you want to decouple your form objects from the model, in simple words, insert another layer between your View and the Model, Reform is all about that.

Reform gives you a form object with validations and nested setup of models. It is completely framework-agnostic and doesn't care about your database.

Installing Reform

Add this line to your gemfile ;

gem 'reform'

Since Reform 2.2, you've to add reform-rails gem to your gemfile to automatically load...

Read complete blog post

ActiveRecord Attributes And Defaults - The Old Way

Imagine that you are in a vacation rental industry and you are adding a new model for handling reservations for rentals, let’s call it Reservation. To keep it simple for the purpose of this example, let’s assume that we need start_date and end_date date fields for handling the duration of the reservations and price field, which is pretty useful unless you are developing an app for a charity organization ;). Let’s say we want to provide some...

Read complete blog post

It is said that ''It is not happy people who are thankful; It is thankful people who are happy''.

An attitude of gratitude means making it a habit to express thankfulness and appreciation in all parts of your life, on a regular basis, for both the big and small things alike. "If you concentrate on what you have, you'll always have more. If you concentrate on what you don't have, you'll never have enough."

We should wake up every day and express to ourself what we are grateful for. We should...

Read complete blog post

Side Loading

Ember Data supports “sideloading” of data; i.e., indicating that data should be retrieved (along with the primary data requested) so as to help multiple related HTTP requests.

A common use case is sideloading associated models. For example, each Shop has many groceries, so we can include all related groceries in /shops response:

GET /shops
{
 "shops": [
 {
 "id": "14",
 "groceries": ["98", "99", "112"]
 }
 ]
}

When...

Read complete blog post

Before starting with setup process lets first briefly go through what Sidekiq is? and how it works? Sidekiq provides very handy and efficient way to perform most of our work asynchronously in a job. Provided Redis cache connection to it, it serializes all job parameters in Redis and deserializes it while picking it up for execution based on priority of job as it uses queue data structure to store each job in particular queue specified in job and each queue has its priority defined as high,...

Read complete blog post

  • A Symbol looks like a variable name but it's prefixed with a colon.

     Examples - :action
    
  • Alternatively, you can consider the colon to mean "thing named" so :id is "the thing named id." You can also think of :id as meaning the name of the variable id, and plain id as meaning the value of the variable.

A Symbol is the most basic Ruby object you can create. It's just a name. Symbols are useful because a given symbol name refers to the same object throughout a Ruby program. Symbols are...

Read complete blog post

Sometimes you’ll want to refer to your image assets from inside of your JavaScript or CoffeeScript files. We have nice rails helpers that would allow us to do so but we need to append .erb to every .js or .coffee file we want to reference images.

I didn’t like it that way, because ERB inside of CoffeeScript looks odd and having the file end with .erb messes up syntax highlighting.

A way around this is by adding following piece of code (not the beautiful one) to one single file that ends on ...

Read complete blog post

What do you do when you need to run the same test multiple times, but with different parameters? If you copy and paste the test, you end up with a hard-to-read test file. You can’t easily tell how the tests differ from one another. Worse, when you need to change one, you need to change them all. Take the following simple test file:

def double_it(number)
 number * 2
end

describe '#double_it' do
 it 'doubles 1 into 2' do
 expect(double_it(1)).to...

Read complete blog post

Sometimes tests can be hard to debug, especially when they’re running on a remote machine.This can be done with ssh enabled build with CircleCi using Debug via SSH option.

SSH can be enabled for already running build or with rebuild option.

  1. To enable SSH access for a running build, go to the ‘Debug via SSH’ tab and click the ‘Enable SSH for this build’ button. enter image description here

  2. To start a fresh build with SSH enabled, for example if you want to debug a build that has already finished, click the ‘with ssh’...

Read complete blog post