All posts by Ramesh Jha

Monitor your bandwidth usage with vnstat [Ubuntu/Linux]

vnstat is a simple command line utility for monitoring bandwidth usage in Ubuntu or any other Linux based distributions and BSD. It’s a very handy tool for keeping an eye on overall bandwidth usage on your system, especially if you’re accessing web over mobile network or you’re using ISP that reduces speed after a certain limit e.g 50 GB (FUP).

vnstat

Features

  • very lightweight and efficient (low cpu usage regardless of traffic)
  • simple and easy to use (no configuration required)
  • it can monitor multiple interfaces simultaneously
  • multiple output options (daily, monthly etc)

Installing vnstat in Ubuntu/Linux

It’s already there in official package repository, all you need to do is open a terminal and type :

sudo apt-get install vnstat

As you install vnstat, it will start monitoring your internet traffic (default interface : eth0). Simply type vnstat to get an overview of actual bandwidth usage and the estimated usage for next day or month. It will also display the interface(s) it’s monitoring.

vnstat

For all available options, type :

vnstat --help

Few commands you should know

  • vnstat -d : for daily stats
  • vnstat -w : for weekly stats
  • vnstat -m : for monthly stats
  • vnstat -l : for analyzing live traffic
  • vnstat -t : shows usage statistics for top 10 days

Deploying static websites to VPS using git

git is a distributed open source version control system. If you’re not already familiar with git then read some free tutorials listed here and come back after you have some basic understanding to follow through the tutorial. Whether it’s a static website or a fun project, it’s usually a good idea to use a version control system such as git. Additionally, git can also help you in deployment and make your development workflow much easier and simpler.

git deployment

Step #1. Server Setup

If you’ve not already selected a VPS then get one there on Digital Ocean or Linode. Make sure you select Ubuntu (preferably : 14.04 LTS) for the server OS. Otherwise, you may need to adjust few commands depending on the Linux distribution you’re using.

Step #2. Configure git on the server

SSH into the remote server and configure git for deployment.

ssh example_user@IP_ADDRESS
mkdir example.git
cd example.git
git init --bare

Next, create a git hook – a shell script that will be executed on git push (to update code on server).

nano ~/example.git/hooks/post-receive

Here is a sample post-receive script you can use : (use Ctrl+X to save and exit)

And make it executable.

chmod +x ~/example.git/hooks/post-receive

Step #3. Install and configure git on dev machine

First, install git, move into your project directory and commit it under git.

sudo apt-get -y install git-core
cd example.com
git init
git add .
git commit -am "MVP is ready for the wild"

Add remote repository for deployment server.

git remote add production ssh://example_user@IP_ADDRESS/~/example.git

And now, you’re ready to deploy. Just type (to push recent changes to live server) :

git push production master

Step #4. Configure nginx

ssh into the server and create a nginx config for the domain (example.com).

sudo nano /etc/nginx/sites-available/example.conf

Here is a sample config you could use :

sudo ln -s /etc/nginx/sites-available/example.conf /etc/nginx/sites-enabled/example.com
sudo service nginx reload

Now, update the DNS settings at the registrar and create two records – one for naked domain (e.g example.com) and other for www-version of the website (e.g www.example.com) – both pointing to the server IP. And, wait for the DNS to be propagated (few minutes).

Calculate your income tax liability using this free online tool [India]

If you’re paying taxes in AY 2015-16 (FY 2014-15) you may want to get a rough estimate before you go to a tax consultant (or do it yourself). For that purpose, you may want to check out this income tax calculator I launched few days ago.

income tax liability

It’s a simple web based tool that helps you get an overview of your total income tax liability (or refund) for the current assessment year. The process is straightforward and simple with step-by-step guide for each sections. (especially for beginners)

income details

 

First, select your age and financial year (2014-15 is selected by default) and enter your income details in 2nd step. Make sure you add all income sources correctly and also the amount of tax paid in advance (TDS, TCS etc).

deductions

Then, you can enter the amounts for eligible deductions before you get to the final report on your tax liability/refund.  The deduction page helps you in the process by offering simple and easy to understand interpretation for various sections including section 80C, 80D, 80G, 80E and so. Make sure you read all the details before moving to the next.

Visit the Website : http://incometaxcalculator.net.in

Update! Also check out this one http://sipcalculator.in if you invest in mutual funds through SIP (Systematic Investment Plan) and http://irr-calculator.com for calculating internal rate of return for an investment.

Fish – A user friendly command line shell for Ubuntu/Linux

Fish is a friendly command line shell for Ubuntu/Linux, Mac or any other operating system from the *nix family. If you use bash (the default shell in Ubuntu) often, then you may want to give it a try. It has lots of smart features you may find productive.

fish shell

Features

  • Autosuggestions – It suggests commands when you type, based on history and it’ll often save you some time with the commands you type more often.
  • Scripting – Similar to bash but the syntax is much simple, clean and consistent.
  • term256 – it supports 256 colors.
  • Sane defaults – Most of the features will work just fine without any additional configurations.

Installing Fish in Ubuntu

Fish is already there in official package repository (tested on Ubuntu 14.04 LTS). So, you can install it right away

sudo apt-get update
sudo apt-get install fish

If it’s not available in repository or you’re using other Linux distribution ? Check out official page to download a tarball for your distribution.

To start fish, simply type fish on your terminal and you’ll jump into the fish shell. Type help and it will open the documentation tab (hosted locally) in your default browser. Also read official tutorials to learn more about the features of Fish Shell.

Skeleton – A lightweight CSS framework for your next side project

Skeleton is a lightweight CSS framework that provides a nice boilerplate to kickstart the development process. I like the minimal design approach. Plus, I can easily add more CSS on the top if required. The grid and some basic styles are more than enough to get started.

Simple Responsive grid

Simple, easy and human friendly grid-naming conventions. Just add a div element with class ‘row’ (with child columns) inside a container and you’re good to go (12 column grid – kind of similar to bootstrap and foundation).

Basic styles for Standard elements

Skeleton comes with basic styles for standard HTML elements such as Headings (h1/h2/h3 etc), basic form elements (input, buttons etc), tables and some utility classes (for left/right alignment, clearing floats etc). Here is how a simple ‘sign in’ form with Skeleton.

Lightweight, fast and easy to override

The Skeleton along with Normalize CSS is less than 10KB when minified. So, it’s a great choice for smaller web projects, side projects, mobile websites, landing pages for your mobile apps etc.

You can download the latest version from the official website : http://getskeleton.com (Current version : 2.0.4). Sass and LESS versions are also available to help you add Skeleton in your preferred development setup.

Also check out my last weekend project – Mobile Number Tracker (India) – I created using Skeleton.