Thursday, January 28, 2016

connect to host postgresql from vagrant guest

user@host:~$ sudo -i
root@host:~$ echo "listen_addresses = '*'" >> /etc/postgresql/9.5/main/postgresql.conf
root@host:~$ echo "host    all             all             0.0.0.0/0            md5" >> /etc/postgresql/9.5/main/pg_hba.conf

root@host:~$ /etc/init.d/postgresql restart


connect to host from guest
user@host:~$ vagrant ssh
vagrant@guest:~$ psql -h 192.168.33.1



Thursday, January 21, 2016

npm install on ubuntu

npm config set registry=http://registry.npmjs.org/

Thursday, October 15, 2015

connect to corporate network from anywhere in internet through amazon ec2 instance

connect to a ubuntu server which resides inside a corporate network, which is more secured by corporate Firewall,  from anywhere in internet.

Assume you have a ubuntu 15.04 server located inside a corporate. corporate_user@corporate_server

if you want to connect to that corporate server from you home or from anywhere else, then you have to use a proxy server like amazon ec2
create a amazon ec2 instance server (named as $ws) with ubuntu 15.04 and enable port 22(enabled by default) and 2222.

now go and initiate a connection from you corporate_server
by typing

ssh -R 2222:localhost:22 -l ubuntu $ws
which will create a connection with ssh reverse port forwarding.

now connect your aws server ($ws) from anywhere and type
ssh -p 2222 corporate_user@localhost

that is nothing but your corporate_server

Tuesday, August 18, 2015

use aws-sdk-ruby in windows behind proxy


Aws.use_bundled_cert!
Aws::S3::Resource.new(http_proxy: "http://proxy.com:8080") 
Aws::S3::Client.new (http_proxy: "http://proxy.com:8080")


Sunday, June 21, 2015

shared network

1) Click "Launche Instance"
2) community AMIs
3) choose Operating System as "windows"
4) choose Architecture as 64 bit
5)  select "Windows_Server-2012-R2_RTM-English-64Bit-Base-2015.06.10 - ami-c5688281"

6) allocate hard disk size to 60 GB
Inbound TCP ruby 135-139 , 445
Inbound UDP ruby 135-139 , 445
enable ports in firewall

Wednesday, May 6, 2015

how to resolve passenger apache to read env variables

https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-passenger-and-apache-on-ubuntu-14-04

Tuesday, May 5, 2015

Enable Public DNS for EC2 instance

http://stackoverflow.com/questions/20941704/ec2-instance-has-no-public-dns

Tuesday, April 21, 2015

how to configure nano editor & Atom Editor

http://askubuntu.com/questions/90013/how-do-i-enable-syntax-highlighting-in-nano
https://atom.io/

Sunday, April 19, 2015

avoid prompt for passprase

eval $(ssh-agent)
ssh-add

read /etc/hosts file by HostAdmin in chrome & ff

https://github.com/tg123/chrome-hostadmin

https://github.com/tg123/chrome-hostadmin/issues/11


Thursday, April 16, 2015

how to assign IP Address to docker container

http://stackoverflow.com/questions/27937185/assign-static-ip-to-docker-container

https://opsbot.com/advanced-docker-networking-pipework/
http://xboxng.com/wp/?p=66

https://opsbot.com/advanced-docker-networking-pipework/

Friday, April 10, 2015

create sublime.desktop launcher in ubuntu unity

user@ubuntu:~/.local/share/applications$ cat sublime.desktop
[Desktop Entry]
Name=Sublime
GenericName=SublimeTest3
X-GNOME-FullName=SublimeText3
Comment=Editor, simple, lightweight
Exec=/home/user/packages/sublime_text_3/sublime_text
Icon=/home/user/packages/sublime_text_3/Icon/48x48/sublime-text.png
Terminal=false
Type=Application
Categories=GNOME;IDE;Editor;Ruby;Golang;
StartupNotify=true
X-Ubuntu-Gettext-Domain=sublimetext
user@ubuntu:~/.local/share/applications$ 

Thursday, April 9, 2015

boot2docker on osX

instal boot2docker pkg in mac os x
then open trerminal
~:$ /usr/local/bin/boot2docker init
~:$ docker info
~:$ /usr/local/bin/boot2docker up && export DOCKER_HOST=tcp://$(/usr/local/bin/boot2docker ip 2 > /dev/null):2375
export DOCKER_HOST=tcp://192.168.59.103:4243
~:$ docker info
~:$ docker run busybox echo hello Docker!


process killer for linux by ruby


if ARGV.size == 0
puts "pass argument"
else
        res = `ps aux | grep '#{ARGV[0]}' | awk '{print $2}'`
end
pids = res.split("\n")
puts pids
pids.each {|e|
  if Process.pid.to_s != e
     puts `ps -p #{e} -o pid,vsz=MEMORY -o user,group=GROUP -o comm,args=ARGS`
     puts `kill -9 #{e}`
     puts "killed"
   end
}
puts "all process are killed and resources releived to Kernel"


Monday, February 16, 2015

create a new rails 5 application and deploy to heroku

how to create a new rails 5 application and deploy it into heroku.
install ruby and rails following by their dependencies.

user@ubuntu-15.04:~$ ruby -v
ruby 2.2.0p0 (2015-01-25 revision 49005) [x86_64-linux]
user@ubuntu-15.04:~$ rails -v
Rails 4.2.0

install edge rails
user@ubuntu-15.04:~$ git clone git@github.com:rails/rails.git ~/packages/edge/rails
user@ubuntu-15.04:~$ export EDGE=/home/user/packages/edge/rails/railties/bin
user@ubuntu-15.04:~$ $EDGE/rails -v
Rails 5.0.0.alpha
user@ubuntu-15.04:~$ $EDGE/rails new --edge --database=postgresql rails-5-demo-blog
user@ubuntu-15.04:~$ cd rails-5-demo-blog


user@ubuntu-15.04:~/rails-5-demo-blog$ git init; git add . ; git commit -m "first commit"
user@ubuntu-15.04:~/rails-5-demo-blog$ $EDGE/rails g --help
user@ubuntu-15.04:~/rails-5-demo-blog$ $EDGE/rails g scaffold Post name desc:text at:timestamp
user@ubuntu-15.04:~/rails-5-demo-blog$ rake db:create; rake db:migrate;


user@ubuntu-15.04:~/rails-5-demo-blog$ git add . ; git commit -m "Post Scaffold Added"
user@ubuntu-15.04:~/rails-5-demo-blog$ $EDGE/rails s

now ,you can browse at localhost:3000

want to run in production

comment this last 2 line in config/database.yml

# username: rails-5-demo-blog
# password: <%= ENV['RAILS_5_DEMO_BLOG_DATABASE_PASSWORD'] %>

add production secret_key into config/secret.yml at last line
<pre>
production:
  secret_key_base: blahblahblah
</pre>
add <pre>root 'posts#index'</pre> into config/routes.rb
add </pre>public/assets/</pre> into .gitignore

user@ubuntu-15.04:~/rails-5-demo-blog$ rake db:create RAILS_ENV=production
user@ubuntu-15.04:~/rails-5-demo-blog$ rake db:migrate RAILS_ENV=production
user@ubuntu-15.04:~/rails-5-demo-blog$ rake assets:precompile
user@ubuntu-15.04:~/rails-5-demo-blog$ RAILS_SERVE_STATIC_FILES=true $EDGE/rails server -e production

now, you can browse your production app at localhost:3000

deploy to heroku

add <pre>ruby '2.2.0'</pre> at top of Gemfile
add <pre>gem 'rails_12factor', group: :production</pre> into Gemfile

user@ubuntu-15.04:~/rails-5-demo-blog$ bundle
user@ubuntu-15.04:~/rails5blog$ git add .;git commit -m "Heroku dependencies Added"


install heroku toolbelt

user@ubuntu-15.04:~/rails-5-demo-blog$ heroku login
user@ubuntu-15.04:~/rails-5-demo-blog$ heroku create
user@ubuntu-15.04:~/rails-5-demo-blog$ git push heroku master
user@ubuntu-15.04:~/rails-5-demo-blog$ heroku run:detached rake db:migrate
user@ubuntu-15.04:~/rails-5-demo-blog$ heroku open

A demo app created at https://github.com/thaniyarasu/rails-5-demo-blog
this demo app deployed into heroku at https://rails-5-demo-blog.herokuapp.com/


Dartium will kill all major web & desktop application in upcoming years


After analyzing All Web Technologies,
i am sure about that , DARTIUM  (dartlang.org) will kill All Mobile & Desktop Application in another 3-7 years.

The Effect of Dartium


1) Dartium will dominate javascript in upcoming years
2) Dartium will kill All Desktop Apps 
3) Dartium will kill All Mobile Native Apps like Android ,IPhone,BlackBerry , Windows Mobile,etc

Go Language , Dart Language, Dartium ,PolymerDart ,AngularDart, Pnacl/NacL are the Future of Web Technologies.

All server side component will be re written in Golang
All client side component will be re written in AngularDart with the support of dartlang and polymerDart


Monday, February 9, 2015

remove homebrew complete in mac

~$ sudo rm -rf /usr/local
~$ sudo mkdir /usr/local
~$ sudo chown -R 777 /usr/local
install homebrew

~$ sudo chown -R $USER /Library/Caches/Homebrew
~$ brew install automake libtool pkg-config gcc48 libyaml readline libksba openssl
install rvm
rvm requirements


Tuesday, November 25, 2014

install rails and deploy to apache2 with assenger

1) install rbenv

2) install ruby
   rbenv install 2.2.0
3) add gem configuration at ~/.gemrc
#######
---
gem: --no-ri --no-rdoc
#######
4) gem update --system
5) gem install rails
5) gem install passenger
6) passenger-install-apache2-module
7) follow and paste the passenger configuration into /etc/apache2/apache2.conf at the end
########
LoadModule passenger_module /home/user/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/passenger-4.0.53/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
  PassengerRoot /home/user/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/passenger-4.0.53
  PassengerDefaultRuby /home/user/.rbenv/versions/2.1.5/bin/ruby
</IfModule>

<VirtualHost *:80>
   ServerName www.hostname.com
   DocumentRoot /somewhere/public  
   <Directory /somewhere/public>
      # This relaxes Apache security settings.
      AllowOverride all
      # MultiViews must be turned off.
      Options -MultiViews
      # Uncomment this if you're on Apache >= 2.4:
      # Require all granted
   </Directory>
</VirtualHost>

#######
8) rails new demo
9) rails g scaffold User name pass age:integer dob:datetime
10) rake db:create:all
11) rake db:migrate RAILS_ENV=production
to start rails server at production then

12) rake assets:precompile RAILS_ENV=production
       add secret to production at config/secret.yml
        production:
          secret_key_base: 9c7...d4d

13) add   'config.serve_static_assets = true'  in config/environments/production.rb
13) add    root 'users#index'  into config/routes.rb
14) rails s -e production
browse at localhost:3000

procedure to deploy into apache2 
15) sudo ln -s /home/user/demo /var/www/demo
13) change   'config.serve_static_assets = false'  in config/environments/production.rb


15) sudo vim /etc/hosts
add  "127.0.0.1  www.myhost.com"

16) modify /etc/apache2/apache2.conf at the end
########
<VirtualHost *:80>
   ServerName www.myhost.com
   DocumentRoot /var/www/demo/public  
   <Directory /var/www/demo/public>
      # This relaxes Apache security settings.
      AllowOverride all
      # MultiViews must be turned off.
      Options -MultiViews
      # Uncomment this if you're on Apache >= 2.4:
      Require all granted
   </Directory>
</VirtualHost>
#######

17) restart the server  sudo /etc/init.d/apache2 restart


locate browser at www.myhost.com
then you should see the home , if not then check log/production.log file









Saturday, May 14, 2011

calling partial in layouts Rails 3.1

in "app/views/layouts" folder should only contain layouts( application , controllers1 , controllers2 , controllers3 , ...)

No more '_partials' inside 'app/views/layouts' folder
lets the '_partials' files can go into corresponding "app/views/#{layout_name}/" folder

you can use the partials from anywhere inside your views
rails will automatically detect corresponding partial files
first preference is for the current_layout in"app/views/#{layout_name}/" folder
next preference is "app/views/application/" folder

Nested Layouts

#controller_names.html.erb
<% content_for :content do %>
something is here
<% end %>
<%= render :template => 'layouts/application' %>


#application.html.erb
<%= content_for?(:content) ? yield(:content) : yield %>

there is a lot of nice futures in rails 3.1
few of those are Sprockets on (Sass + Coffescript) is very nice for development , Streaming , etc