Install pdftk server on mac using home brew

Install pdftk server on mac using home brew
brew tap docmunch/pdftk
brew install pdftk

Deploy Rails 4.2 application with ruby 2.2 and nginx passenger on amazon ec2

Deploy Rails 4.2 application with ruby 2.2 and nginx passenger on amazon ec2

Deploying Rails 4.2 application with nginx + passenger is so easy.

Step 1
Setup EC2 server with ubuntu 14.04
Install ruby 2.2.2 and setup one database like PG etc.
This can be done following this

Once all the basic setup is done.
Now install nginx with passenger.
Follow following steps to do it.

you can now install Passenger on Ubuntu with the Advanced Packaging Tool (APT)

sudo apt-key adv --keyserver --recv-keys 561F9B9CAC40B2F7

Create an APT source file (you will need sudo privileges):

sudo vim /etc/apt/sources.list.d/passenger.list

And insert the following line in the file:

deb trusty main

Update the APT cache:

sudo apt-get update

Finally, install Passenger with Nginx:

sudo apt-get install nginx-extras passenger

Open the Nginx configuration file:

sudo vim /etc/nginx/nginx.conf

Find the following lines, in the http block:

# Phusion Passenger config
# Uncomment it if you installed passenger or passenger-enterprise
# passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
# passenger_ruby /usr/bin/passenger_free_ruby;

Uncomment both of them. Update the path in the passenger_ruby line. They should look like this:

passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /usr/bin/passenger_free_ruby;

We need to disable the default Nginx configuration. Open the Nginx config file:

sudo vim /etc/nginx/sites-available/default

Find the lines:

listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

Comment them out, like this:

# listen 80 default_server;
# listen [::]:80 default_server ipv6only=on;

Save the file.

Now, create an Nginx configuration file for your rails app:

sudo vim /etc/nginx/sites-available/appname

Add the following server block. The settings are explained below.

server {
  listen 80 default_server;
  listen [::]:80 default_server ipv6only=on;

  passenger_enabled on;
  passenger_app_env production;
  root /home/ubuntu/appname/public;
  # redirect server error pages to the static page /50x.html
  error_page   500 502 503 504  /50x.html;
  location = /50x.html {
    root /home/ubuntu/appname/public;

Create a symlink for it:

sudo ln -s /etc/nginx/sites-available/appname /etc/nginx/sites-enabled/appname

Restart Nginx:

sudo service nginx restart

Now your app’s website should be accessible.

Updating code and assets:

rake assets:precompile RAILS_ENV=production
touch tmp/restart.txt

A Checklist for Personal Efficiency

1. Plan your day in advance.
Don’t just start work. Take 15 minutes to carefully go through what your tasks are, get them all down on paper. Next , decide when you will do each item throughout the day. Only then should you begin your day’s work. Such planning may look like a waste of time, but it usually doubles the speed at which your To Do list gets done.
As Abraham Lincoln said, ” If I had six hours to cut down a tree I’d spend the first four hours sharpening the axe.”

2. Do the most important tasks first.
Let’s face it, these days there is simply not enough time to get all your To Do’s done. So if you don’t do your most crucial jobs first, many days you will find they never get done at all.

3. Rush unimportant tasks.
This is a rarely mentioned technique of efficiency. You can unlock huge amounts of time by rushing jobs that don’t matter much. As Warren Buffettput it, “Whats’ not worth doing is not worth doing well.”

4. Work in uninterrupted blocks.
Interruptions destroy efficiency. The more you can find a quiet place to work uninterrupted on your To Do’s, the more you’ll get done. Consider working two mornings a week at a nearby coffee shop. Or book a meeting room at your office and post a big ‘Do Not Disturb’ sign on the door.

5. Don’t do emails until 11am.
When you start work, glance at your emails for anything truly urgent. (This should take no more than ten minutes). Then forget about email until mid morning. Don’t be one of those people that puts everyone else’s priorities before your own.

6. Pick one key job for the day.
What’s the one task that would help your business the most? Get clear on this, each and every day. If all you did was achieve your single most important task daily, in 3 months your business would be powering. But most people have never identified what their key daily task is.

7. Have a finishing time.
Everyone has a start time, but few have a time they must leave at the end of the day. You’d be amazed how much more efficient you become when you do. When you know there’s a certain time you must finish work, it forces you to work quickly all through the day so you can make the deadline. But when your work day is open ended, there’s no real need to work fast. Remember Parkinson’s Law: “Work expands to fill the time allotted for it.”

So that’s your personal efficiency checklist. Keep it nearby as you work through your day.

If you can stick to this list daily you will find you will radically change how much you achieve. You’ll be able to work less and earn more. Your stress will go down and your confidence will go up.

Host Static Sites on Heroku in Ruby – use puma as produstion server

Follow this Heroku Article.

Once your are done with above article follow bellow to use puma as production server.

By default heroku runs webrick on production.

Add some code  in your static website you can use Puma ad your production server.

Add puma and foreman in your Gemfile

Than run bundle install to install above gems.

Now Add Procfile at root of your application

> cat Procfile

Set Puma as the server for your web process in the Procfile of your application. You can set most values inline:

web: bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-production}

Now you are done. Just commit your code and deploy to heroku.

Here you will see now heroku is using Puma as application server.

Digital Ocean referral