Friday, November 27, 2015

My super power of forgetting password let to "Reveal Password" chrome extension


People are different because each of them possess certain unique capabilities and I am no different. I have this unique ability of quickly forgetting my passwords. Oh heck, who has the time to remember passwords, right? You can save your passwords and this feature is already provided by most of the browser and what I meant by "most of the" is chrome and firefox. They are the only two browsers I use and I have no idea for the rest, I am sorry.

It may be very weird to hear that I can not remember my password and I call myself a programmer. haha, common guys it is weird right?

So ya that is my super power and I do not want to show my super power. Just as batman wears a cape and mask and changes his voice I too had to do something to hide my power. Out of all the things in the world all I am capable of doing is coding. So instead of sewing cape and a mask and putting on a hoarse voice I decided to write a chrome extension that would reveal my password. Hey do not get excited, it is nothing fancy because I chose not to wear my underpants outside my costume.

Ok like I have already said, browsers already have a built in function to save the password if you let it to and it will remember that very specific password for that specific site. But the catch is the password field is unfathomable.

What if you had saved all your passwords in your chrome and you browsed firefox? If you are like me, we should be friends, no lets be best friends, you are screwed. But as I know some tricks like opening a inspector and then blabla that is very tedious to do every time plus if you do not have knowledge of inspector tool then you are really screwed.So ya at this situation, you can use my extension and then just like the batman coming out of nowhere,  baam, boom, kapow, no more dots in your password field. You can now know what was you password and live happily ever after.

Well I am still looking for a princess so my story does not end there. I use VC`s a lot and stupidly and indolently I avoided adding ssh keys. So yo know I had to go to the main site , then logout and then check through my inspector and then log in again.Well, now no more.

Here is a link to the codebase .
Download the extension here

Thursday, November 26, 2015

Why I moved from capistrano to mina to deploy my app?


To be honest, I have just started to use deployment tools because doing the same thing over and over again was getting very tedious for me. I first started with capistrano and it was good I guess.

Why I prefer Mina over Capistrano?

While Capistrano is a really really great tool , it is terribly slow. Since time is money for every one of us, I wanted a tool that would not be so painfully slow and easy to use, you know , that get shits done. Then I met Mina and instantly fell in love with it when I browsed its homepage and read its slogan "Really fast deployer  and server automation tool" .

Before I was using any deployment tools I was manually ssh`ing into my server and then cloning the repo from the git then running bundle install , rake db:migrate and a lot of stuffs that is not very interesting to do repeatedly. If I had pushed any new updates to the repo I would have to ssh into the server and do the same thing which is time consuming as well as not very productive. So I highly reckon anyone who is not using deployment tools to use it and feel its power. But remember Great power comes with Great responsibility. :)

It is dead simple to get started with Mina. All you have to do is add a gem run the bundler, create a deploy.rb file , fill the right info in it and running mina deploy. The best part is you can write rake tasks in deploy.rb.

Either run gem install mina or add mina gem in your gemfile.
Run bundle install if you chose the later option.
run mina init in your working directory
Here is my deploy.rb file
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'

# Basic settings:
#   domain       - The hostname to SSH to.
#   deploy_to    - Path to deploy into.
#   repository   - Git repo to clone from. (needed by mina/git)
#   branch       - Branch name to deploy. (needed by mina/git)

set :user, 'ubuntu'
set :domain, 'www.fuitter.com'
set :deploy_to, '/usr/share/nginx/html/fuitter'
set :repository, 'git@bitbucket.org:mc_cannibal/fuitter2.git'
set :branch, 'master'
set :forward_agent, true

# Manually create these paths in shared/ (eg: shared/config/database.yml) in your server.
# They will be linked in the 'deploy:link_shared_paths' step.
set :shared_paths, ['config/database.yml', 'config/secrets.yml', 'log']

# Optional settings:
#   set :user, 'foobar'    # Username in the server to SSH to.
#   set :port, '30000'     # SSH port number.
#   set :forward_agent, true     # SSH forward_agent.

# This task is the environment that is loaded for most commands, such as
# `mina deploy` or `mina rake`.
task :environment do
  ruby_version = File.read('.ruby-version').strip
  raise "Couldn't determine Ruby version: Do you have a file .ruby-version in your project root?" if ruby_version.empty?
 queue %{
   source /home/ubuntu/.rvm/bin/rvm
   rvm use #{ruby_version} || exit 1
 }
end

task :setup => :environment do
  queue! %[mkdir -p "#{deploy_to}/#{shared_path}/log"]
  queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/log"]

  queue! %[mkdir -p "#{deploy_to}/#{shared_path}/config"]

  # Add the repository server to .ssh/known_hosts
  if repository
    repo_host = repository.split(%r{@|://}).last.split(%r{:|\/}).first
    repo_port = /:([0-9]+)/.match(repository) && /:([0-9]+)/.match(repository)[1] || '22'

    queue! %[
      if ! ssh-keygen -H  -F #{repo_host} &>/dev/null; then
        ssh-keyscan -t rsa -p #{repo_port} -H #{repo_host} >> ~/.ssh/known_hosts
      fi
    ]
  end

  # Create database.yml for Postgres if it doesn't exist
  path_database_yml = "#{deploy_to}/#{shared_path}/config/database.yml"
  database_yml = %[production:
  database: fuitter
  adapter: postgresql
  pool: 5
  timeout: 5000]
  queue! %[ test -e #{path_database_yml} || echo "#{database_yml}" > #{path_database_yml} ]

  # Create secrets.yml if it doesn't exist
  path_secrets_yml = "#{deploy_to}/#{shared_path}/config/secrets.yml"
  secret =
  secrets_yml = %[production:
  secret_key_base:
    #{`rake secret`.strip}]
  queue! %[ test -e #{path_secrets_yml} || echo "#{secrets_yml}" > #{path_secrets_yml} ]

  queue! %[chmod g+rx,u+rwx,o-rwx "#{deploy_to}/#{shared_path}/config"]

end

desc "Deploys the current version to the server."
task :deploy => :environment do
  to :before_hook do
    # Put things to run locally before ssh
  end
  deploy do
    # Put things that will set up an empty directory into a fully set-up
    # instance of your project.
    invoke :'git:clone'
    invoke :'deploy:link_shared_paths'
    invoke :'bundle:install'
    invoke :'rails:db_migrate'
    invoke :'rails:assets_precompile'
    invoke :'deploy:cleanup'

    to :launch do
      # queue "mkdir -p #{deploy_to}/#{current_path}/tmp/"
      # queue "service #{user} restart"
    end
  end
end

# For help in making your deploy script, see the Mina documentation:
#
#  - http://nadarei.co/mina
#  - http://nadarei.co/mina/tasks
#  - http://nadarei.co/mina/settings
#  - http://nadarei.co/mina/helpers

then run mina setup and finally mina deploy.
That is all there is to it.

Saturday, November 21, 2015

Hiking to chisapani (A must do hike)


TL;DR
Chisapani is very expensive but it is even more expensive for foreign tourist. I would highly recommend to take some dry foods from home.
It took us 7hrs to reach chisapani from sundarijal, and 5 hrs to get back to sundarijal from chisapani.
Warm clothes is a must because it gets frigid at night and in morning.
Great view of mountain (Langtang, annapurna range, MT everest, ganesh himal)
Ever wondered how a sky full of stars looks like?  Get out of the lodge or hotel in somewhere between 11pm - 3am and look up at the sky.
Safe for solo hike too.

price list(this does not apply to foreign tourist)
plain tea Rs 20
hard boiled eggs Rs 30
plain pankcakes Rs 60
plain dinner Rs 200
room Rs 800 - 500
marijuana Rs 250
coconut biscuit Rs 25
jumbo wai wai noodles Rs 150
local alcohol Rs 100

Link to all the pics

About 8 months ago, I heard about this place via my colleague, then I did some research but could not find much resources on the internet however the ones I found were enough for me to add this place in my wish list. I was planning to go alone but a friend of mine showed interest in going there too so I formed a group of 6 peeps and we left for sundarijal at 7 am from old bus park.

Selfie from the roof of the bus
To make our ride up to sundarijaal adventurous we traveled on the roof of the bus. Since, I had the responsibility of taking care of expenses I had to pay Rs 250 for the fare.

View from the hotel we had our breakfast at

After reaching sundarijal we took a light breakfast (6 eggs, 6 doughnuts, 2 plate fried chickpea, 1 plate fried aloo, 3 bowl of tarkari ) spending a total of Rs 300 and resumed our hike afterwards.



It felt really great to see these huge metal pipes in reality than read about them in the blogs I found.

Rainbow
Entering Shivapuri National Park



To start our chispani hike, I had to pay Rs 50 just to enter the hiking trail.



We swam in this river

First visual of the mountain
We stopped for chyang in one of the hotel along the way and the owner was very gregarious. He shared how devastating the earthquake was to him as he had loose his house. Up to this point, foods are very cheap compared to chisapani. We paid a total of Rs 135 and they also filled the remaining chyang in their own bottles and did not charged us for it and they also filled our water bottle with drinking water. He then showed us the way to chisapani and we left. We got so excited when we had our first visual of the mountain.
The only river to accompany in the whole hiking trail






First visual of Chisapani
Walking for almost 6 hrs we were so exhausted and hungry. All the way we talked about how tasty the fried chicken in the dinner was yesterday. When we saw hotels at Chisapani, we all got excited.


Mountains as seen from Chisapani

Destruction caused by earthquake
After reaching there, we sat down for tea and 2 packets of biscuits for each of us as there was nothing much to eat at the hotel. A packet of biscuit cost Rs 15 and plain tea cost Rs 25. We then found a cheap lodge. I paid Rs 500 for a room, Rs 60/pancake, Rs 30 for an egg and Rs 200/person for dinner. We had brought 6 cans of tuna with us so dinner was really like a feast.
Sun rise in morning

Again, mountains
It was a very fun hike up to chisapani but there is a lot of pollution along the trail. Well the good thing is we completed this whole hike in just Rs 6000 and staying in budget.