Blog


We live in world where people make their Facebook profile “public” while LinkedIn profile is still “private”.




Startup Rule #3

If you are willing to work 80 hours a week to avoid a 40 hours a week job, then and only then you are suited for a start-up.




PhotoBlog- Trek in Dalhousie

An awesome trek comes to the end, 50,000+ steps, 3,000+ feet up and down, 1,000+ photographs(2000+ counting Arya’s selfies), a lost phone and a lot of memories.

Truly, an awesome experience, it was.


Let’s, check out some photographs.

Oooooh, this view still gives me the chills.

image

Notice anything? These are the clouds! Ha! We are heaven.

image

The squad ready to roll!

image

Pure bliss!

image

That’s me sitting on a mountain top corner!

image

As they say, everything good comes to an end.
The trek came to the end. But will live forever in our hearts. 🙂

Gaurav.




How I created an API in less than an HOUR!

Check out the API on https://city-api.herokuapp.com/

Okay, first things first, 2 days back one of my friends asked me to help in building an application where he was using some API to make calls and do some “stuff”. Sure, I helped him. But with that I was wondering what would it take to build an API of my own.

Then, today I was looking for some of the methods available for forms, where you have to first select COUNTRY and then CITIES load asynchronously.

Interestingly, most of the methods that exist require you to store the information in your own database (BUT, this puts extra load on your database, and you don’t even need this data unless user is filling forms). So I though why not create an API for that!

Enough with the reason, for why I created the API!

Let’s start building one.

Environment:

Application Framework: Ruby on Rails

Database: postgreSQL

Hosting Provider: Heroku

Text Editor: Sublime Text 3

  • To start building the application you need to have ruby and rails setup on your computer system. (Google it for help)
  • In the terminal type command rails new cityapi, this will create some files and directory. After finishing move into the directory and open the folder in Sublime.
  • Now download the CSV file for city data from Geolite.(For convenience you can remove columns(except city and country) from the file). Put the file in the root folder of your app.
  • Now create an model called city.

Command – rails g model city name:string country:string

  • Generate controller and views.

Command – rails g controller city 

  • Modify routes for

get ’/’ => ‘city#index’.

  • In the gemfile (for postgreSQL) add
 gem ‘pg’
  • Add some code for seeding the database from CSV file.

require ‘csv’

puts “Importing countries…”
num = 1
CSV.foreach(Rails.root.join(“countries.csv”), headers: true) do |row|
City.create! do |city|
city.id = num
city.country = row[0]
city.name = row[1]
num += 1
end
end

  • Add an index method in city controller, defined as:

The below mentioned content helps the application to generate response in accordance with the API request. SQL query is made depending upon the parameters and a JSON response is generated for the user.

def index
if params[:country].present?
@cities = City.where(‘country ILIKE ?’, params[:country]).pluck(:name)
if @cities.present?
respond_to do |format|
format.html { render json: @cities, status: :ok }
format.json { render json: @cities, status: :ok }
end
else
respond_to do |format|
format.html { render json: [“Error”], status: :not_found }
format.json { render json: [“Error”], status: :not_found }
end
end
end

if params[:city].present?
@country = City.where(‘name ILIKE ?’, params[:city]).pluck(:country)
if @country.present?
respond_to do |format|
format.html { render json: @country, status: :ok }
format.json { render json: @country, status: :ok }
end
else
respond_to do |format|
format.html { render json: [“Error”], status: :not_found }
format.json { render json: [“Error”], status: :not_found }
end
end
end
end

  • We are almost done!
  • Modify the view/city/index.html.erb as you like. It will sever as homepage.
  • Go to heroku.com and signup. Create an application and get application name.
  • Now some commands in sequence to make your application live.

heroku git:remote -a your_heroku_app_name

git init 

git add –all

git commit -m “first commit”

git push heroku master

heroku run rake db:migrate

heroku run rake db:seed

  • What are you waiting for, go check your application/API.

This was one of my fastest developed application. (Writing this blog post took more time than the application :P). If you haven’t checked out the application yet go ahead give it a try https://city-api.herokuapp.com/.

If you want you can check out the git repo too, visit: cityAPI.

P.S.- Do comment for help/queries and suggestions.




The biggest communication problem is we do not listen to understand. We listen to reply.




Follow a post without commenting ‘#’ or ‘#following’. (Facebook)

A lot of people do this(image below) to follow a post/status from certain groups and pages, but there is an easy way to do that.

image

It’s a two-step-process and you can follow any post discreetly. Here it goes.

0. Go to the post you want to follow.

1. Click on that(marked in image) icon.

image

2. Click on ‘Get Notifications’. And you’re done!

image

Like and Share,

Gaurav Goyal




Android ‘L’

Perfect!
At this level, with so much innovations already done by Google, it’s the minor things that matter. Now, you don’t need features like active notifications and whatnot because they are already there, you just need to make them more user-friendly, easy and intuitive. The things done with ‘L’ to bring android features to various device types is incredible.
And if you want, you can check out latest Google+ app, to see a preview of material design.

P.S. – One thing you might have noticed in WWDC, that most of the features announced for iOS 8 are available in Android since ICS.




Startup rule #2

If you aren’t paying for it, then you; are the ‘product’, not the ‘customer’ .




Startup rule #1

You only need a Hacker and a Pirate to start-up.




There are 10 types of people in the world: those who understand binary, and those who don’t.

Unknown