Bookmark and Share

Gulp is a toolkit for automating painful or time-consuming tasks in your development workflow, so you can stop messing around and build something. You can compile sass files, uglify and compress js files and much more.


Make sure that you’ve installed Node and npm before attempting to install gulp.

Install the gulp command

Make sure that you have your package.json created by manually creating it or typing npm init.

Run this command in your project directory:

Create a gulpfile

In your project directory, create a file named gulpfile.js in your project root with these contents:

The first step to using Gulp is to require it in the gulpfile. Then you can begin to write a gulp task with this gulp variable. task-name refers to the name of the task, which would be used whenever you want to run a task in Gulp. You can also run the same task in the command line by writing gulp task-name.

Run the gulp command in your project directory:

To run multiple tasks, you can use gulp <task> <othertask>

Gulp tasks are usually a bit more complex than this. It usually contains two additional Gulp methods, plus a variety of Gulp plugins.

gulp.src tells the Gulp task what files to use for the task, while gulp.desttells Gulp where to output the files once the task is …

Read More

Background Workers using Crontab

Bookmark and Share

Scheduling background jobs is a common task in rails application development. Eventually what we want is a cron job which runs the schedule jobs.

cron is the system process which will automatically perform tasks for you according to a set schedule. The schedule is called the crontab, which is also the name of the program used to edit that schedule.

For example, let’s say you have a rake task which you want to run every hour.

To edit the crontab, use this command:

Now let’s add our job to the crontab. Each job you add should take up a single line.

The format is very simple: six pieces of information, each separated by a space; the first five pieces of information tell cron when to run the job, and the last piece of information tells cron what the job is.

m, representing the minute of the hour, h, representing the hour of the day, dom, representing the day of the month, mon, representing the month of the year, dow, representing the day of the week and  command, which is the command to be run. For example in our case

The asterisks (“*“) will tell cron that for that unit of time, the job should run ‘every’. …

Read More

Cheat sheet for managing files from Ruby

Bookmark and Share

In this Cheat sheet, you will learn managing files from Ruby.

Files are used for storing the Data for a Long time Period. And the files can contain any type of information means they can Store the text, any Images or Pictures or any data in any Format. It is associated with class IO File includes.

Creating a New File

New files are created in Ruby using the new method of the File class. The new method accepts two arguments, the first being the name of the file to be created and the second being the mode in which the file is to open. Like,

file =“filename”, “mode”)


Supported modes are:

Read only access.

Read and write access.

Write only access.

Read and write access.

Write only access.

Read and write access.

Opening Existing Files

You can open the existing files using the open method.


If the file is already opened, we can close it by using the close method.


Reading and Writing Files

Once we’ve opened an existing file or created a new file we need to be able to read from and write to that file. We can read/write using different methods.

sysread Method:

You can use the method sysread to read the contents of a file.


This statement …

Read More

Get into Sentiment Analysis with Ruby

Bookmark and Share


Sometimes we fail to understand other’s emotion. So how it will be when machines try to understand ours? When writing programs we care about the syntax and structures but these concerns are not there in communication between people. To process our language machines have to understand not only what we say, but what we mean. Natural language processing is a fascinating subject to explore. But what makes it complicated?

Human communication isn’t just a group of words. It’s a mix of sentiments which needed to be analyzed to understand what we really mean.

Why should I care

The contemporary business world is a place where huge success and failure sit side by side. In traditional market research, business spends a huge amount to analyze customer’s opinions through continuous surveys and consultants. But nowadays social media empowers business a lot. Most the existing and potential customers are generating a treasure trove of data through Twitter, Facebook, LinkedIn and so on. Sentiment analysis is a powerful tool for mining the gold beneath the social media landslide.

The goal of sentiment analysis is to identify the opinions expressed in a text.

It seems easy, right?

  • I’m happy to watch a new movie
  • I hate war
  • Since …

    Read More

    Refactoring in Rails

    Bookmark and Share


    When the complexity of our Rails application increases, it becomes difficult to test and add new features. As we know, Rails is built on the principle of convention over configuration. Putting too much logic in the controller will eventually violate the single responsibility principle making future changes to the codebase difficult and error-prone. Refactoring the code helps for quality, clarity, and maintainability.

    When should we refactor?

    Tests usually run faster with well-isolated code. Slow running tests indicate the need of more sophisticated design. For example, each class should be concerned about one unique functionality. Also, models and controllers with too many lines of code needed to be refactored to make code DRY and clean. We can use best approaches of Object Oriented Programming to achieve this.

    Consider the following example of a controller where the whole logic for creation and deletion is concentrated.


    Moving a big controller’s action to service objects

    To achieve the new design, keep controllers as thin as possible and always call service objects. Controllers are a good place to have the HTTP routing, parameters parsing, authentication, calling the right service, exception catching, response formatting, and returning the right HTTP status code. A service …

    Read More

    Getting started with Angular 4

    Bookmark and Share

    Angular is a most popular platform for building applications with the web. Angular empowers developers to build applications that live on the web, mobile, or the desktop. The AngularCLI is a command line interface tool that can create a project, add files, and perform a variety of ongoing development tasks such as testing, bundling, and deployment.

    As compared to the older versions of Angular, there are many new things added to the list. Not only new features but also some twists are there that enhance old features. Forget Angular 3, Google jumps straight to Angular 4 after Angular 2. Angular4 applications are much faster and less space consuming.  Angular4 is compatible with TypeScript’s newer versions 2.1 and 2.2. Components are the basic building blocks of your application. Every component has an associated template, style sheet, and a class with logic.


    1. NodeJS ( 6.x.x or greater )

    2. npm (3.x.x or greater )


    1. You have to install AngularCLI globally.

    2. Create a new project.

    3. To serve the application, get into the project repo and run :

    For launching our server and for rebuilding our app …

    Read More

    Rails Generators

    Bookmark and Share

    Rails generators are used to create many files for models, controllers, views, unit tests, migrations and more. It will do some of the manual work for us. So it saves time. They can also be used to set up some basic specs for the application test suite.

    Running rails generate(or rails g) by itself gives a list of available generators:

    The main generators that rails offers are:

    • controller: The Rails controller coordinates the interaction between the user, the views, and the model.
    • helper: Code in helpers is included in the corresponding view. We can move big loops, method calls or other logic into a method in the helper.
    • mailer: It allows for sending and receiving emails from and to your application.
    • migration: Rails Migration allows you to use Ruby to define changes to your database schema.
    • model: It is Ruby class that talk to the database, store and validate data, perform the business logic.
    • scaffold: It refers to the auto-generation of a simple set of a model, views and controller usually for a single table.

    Following is the list of options, which can be used along with generators:

    -h, [–help] # Print generator’s options and usage
    -p, [–pretend] # Run but do not make any changes
    -f, [–force] …

    Read More

    PostgreSQL 9.6 new features

    Bookmark and Share

    POSTGRESQL is an open-source object-relational database system. It is not controlled by any corporation or other private entity. The source code is available free of charge. PostgreSQL supports transactions, subselects, triggers, views, foreign key referential integrity, and sophisticated locking.

    New features in Postgres are:

    • Parallel execution of sequential scans, joins and aggregates.
    • Avoid scanning pages unnecessarily during vacuum freeze operations.
    • Synchronous replication now allows multiple standby servers for increased reliability.
    • Full-text search can now search for phrases (multiple adjacent words).
    • postgres_fdw now supports remote joins, sorts, UPDATEs, and DELETEs.
    • Substantial performance improvements, especially in the area of scalability on multi-CPU-socket servers.

    Parallel execution of sequential scans, joins and aggregates

    PostgreSQL can devise query plans which can leverage multiple CPUs in order to answer queries faster. This feature is known as the parallel query. Mostly, queries that touch a large amount of data but return only a few rows to the user will get benefit by using Parallel Query. It can now execute a full table scan in multiple parallel processes, up to the limits set by the user.

    Avoid scanning pages unnecessarily during vacuum freeze operations

    Freezing …

    Read More

    Web Frameworks in Crystal

    Bookmark and Share


    The creator of Ruby, Yukihiro Matsumoto said that the language was made to make programmers happy. Imagine a language as elegant as Ruby and blazingly fast as C. If you already love Ruby, maybe it is time to start considering Crystal lang, the younger sibling of Ruby. It is a compiled language which is syntactically very similar to Ruby and designed for high throughput and performance.


    • Native WebSocket support
    • Compiles to efficient native code
    • Statically typed => if any errors it will let you know at compile time.
    • Less memory consumption

    Web frameworks in Crystal

    Applications developed using framework are easy to maintain and upgrade at a lower cost. This article lets you get familiar with some of the most popular frameworks of Crystal.

    Install Crystal to get started.

    Create our Crystal app


    To know the true potential of Crystal, let’s familiarise with Kemal, most popular Crystal framework. It’s a Sinatra inspired framework.

    Install Kemal

    In our app,

    Open in an editor and add Kemal as a dependency in the shard.yml file.

    To get dependencies, run

    This will install Kemal.

    This is similar to adding gems in gem file and bundle install in Rails.

    In the file created in the src directory, substitute the following

    In the …

    Read More

    Event Listeners in VueJS

    Bookmark and Share

    Vue.js is a Javascript framework for user interface. There are many directives in Vuejs. A directive’s job is to reactively apply special behavior to the DOM when the value of its expression changes. You can use the v-on directive to bind event listeners to DOM events.

    We are binding a click event listener to a method named clickMe. Here’s how to define that method in our Vue instance. Here we have a counter variable initialized to zero. Inside the method, we are incrementing the value of the counter. So for each click on the button, the method is invoked. You will get the code here.

    Here in this example, we are using two button and methods. One for incrementing the count and other for decrementing. You can see code here.

    Note :-

    For example,

    This will give same result as before.

    We can see another example. Here we have an input field where we type the url which is bound to the Js using v-model.  We have a button with click event listener which is bound to the method humanizeUrl. We have two urls, url and cleanUrl. url  is what we type in the input field and …

    Read More