Skip to content

Instantly share code, notes, and snippets.

View ketanghumatkar's full-sized avatar

Ketan Ghumatkar ketanghumatkar

View GitHub Profile

Install Nodejs

sudo npm install -g n
sudo npm cache clean -f
sudo n 4.3.1
node -v 

Install java

@ketanghumatkar
ketanghumatkar / add_client.rb
Last active September 15, 2015 11:44 — forked from umar-webonise/add_client.rb
Added Client in treeni Data Management : after adding multitenancy
client = Client.new(name: 'Treeni')
client.save!
files = Dir["app/models/*.rb"]
models = files.map { |file| file.split('/').last.sub(/\.rb/, '').camelize.constantize }.select { |i| i != Client }
models.each { |model| model.update_all(client_id: client._id) }
#resetting the password of postgresql
sudo -u postgres psql postgres
postgres=# \password postgres
(function(ctx, $, undefined){
$(document).ready(function(){
bindEvent();
})
function bindEvent () {
//private scope for application
}
sudo add-apt-repository ppa:pitti/postgresql
sudo apt-get update
sudo apt-get install postgresql-9.2 postgresql-server-dev-9.2 postgresql-contrib-9.2
sudo su -l postgres
psql -d template1 -p 5433
CREATE EXTENSION IF NOT EXISTS hstore;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
service postgresql stop
/usr/lib/postgresql/9.2/bin/pg_upgrade -b /usr/lib/postgresql/9.1/bin -B /usr/lib/postgresql/9.2/bin -d /var/lib/postgresql/9.1/main/ -D /var/lib/postgresql/9.2/main/ -O "-c config_file=/etc/postgresql/9.2/main/postgresql.conf" -o "-c config_file=/etc/postgresql/9.1/main/postgresql.conf"
@ketanghumatkar
ketanghumatkar / zsh.md
Created February 7, 2014 18:39 — forked from tsabat/zsh.md
# config/initializers/will_paginate.rb
module WillPaginate
module ActionView
def will_paginate(collection = nil, options = {})
options[:renderer] ||= BootstrapLinkRenderer
super.try :html_safe
end
class BootstrapLinkRenderer < LinkRenderer
@ketanghumatkar
ketanghumatkar / _flash_messages.html.erb
Last active December 31, 2015 22:08 — forked from roberto/_flash_messages.html.erb
Rails flash message handler to include bootstrap classes
<% flash.each do |type, message| %>
<div class="alert <%= bootstrap_class_for(type) %> fade in">
<button class="close" data-dismiss="alert">×</button>
<%= message %>
</div>
<% end %>

Ubuntu 12.04, Ruby, Rails, Nginx, Unicorn and git-deploy

In the seemlingly endless search for the actual correct and easy way to deploy a Rails app, we have tried several ways. We tried out using Apache2 and running a cluster of Thin servers. With the built in threading of Puma we decided to use it with Nginx.

Server Setup

  • Create new server
  • Login to new server
    • ssh root@IPaddress (you can also use the domain name if you have the DNS setup already)
    • accept the RSA key