Thursday, December 15, 2016

steps to add project to git repo locally

Note: In the below step , I have used a project named "my_project"  . Install git and create a account in github before follow the below steps.

Github Link : https://github.com/

In Ubuntu flavoured system :

sudo apt-get install git

My project directory is :

/home/cision/project/my_project>



  1.  cd /home/cision/project/my_project>
  2. git config --global user.name 'username'
  3. git config --global user.email 'your registered emails id in github'
  4. git init
  5. git add -A
  6. git status 
  7. git commit -m "initialize repository'
safeguard : In case any damage in local project directory ( not the git repository ) use th ebelow command to restore from git to project directory 

Ex: remove any file from project directory , then 

# git checkout -f

Now you can see the same deleted file again in the project directory.








Wednesday, August 10, 2016

Arangodb3 basic shell tutorials:

Hope arangodb is already installed !

1) check if the arangodb is already installed ?

curl http://localhost:8529/_api/version   => here it will give the details of the arangodb version in json format.

2) login to arangodb shell

arangosh    =>  provide the arangodb root password

3) create a user

require ("org/arangodb/users").save("khirod","khirod");

4) Grant _system access to user khirod

require("org/arangodb/users").grantDatabase("khirod","_system");


next  coming soon ....



Monday, August 8, 2016

Some Ruby tips :

1) use literal array instead of ['test', 'test1']

ex :  %w(test test1)

2) check with multiple values

ex: %w(val1 val2 val3).include?(check_val)


Monday, May 9, 2016

How to Start Juniper VPN through firefox in 64 bit Ubuntu OS

Unless you need 64bit firefox , try the below steps

sudo apt-get purge openjdk-\* icedtea-\* icedtea6-\*
sudo apt-get install firefox:i386 openjdk-6-jdk:i386 icedtea-6-plugin:i386
sudo apt-get install xterm

OR

1) download and install 32bit java
2) Then install 32bit java through update-alternatives .

Ex:
sudo update-alternatives --install /usr/bin/java java /home/user/programs/java/jdk1.7.0_75/bin/java 10

3) restart firefox
 

else

follow the below link
https://www.java.com/en/download/help/enable_browser_ubuntu.xml

Tuesday, December 29, 2015

secured wifi disconnect in mint

Please create the below file with below content and reboot the system to overcome from regular disconnection of secured wifi connection.  I have tried in mint 17.3 and it works. Please let me know if it fail with proper log.


echo "options rtl8723be fwlps=N ips=N" | sudo tee /etc/modprobe.d/rtl8723be.conf


Tuesday, September 15, 2015

Rest service to get the name node Host ID from thousand of node from cloudera hadoop cluster


1) get the cluster name

clustername = HttpClient(http://:7180/api/v10/clusters)

2) now get the  HostID

host_id=HttpClient(http://:7180/api/v10/clusters/${clustername}/services/hdfs/roles)

3) Now get the Hostname which is on with Namenode

host_name=HttpClient(http://:7180/api/v10/hosts/fb50e775-33b7-4f38-b268-2bb3220695e1)

Now you have the host name which is on with name node .

NOTE : Here I just used HttpClient as a sample method which will get the details from rest service and parse as per the requirements.




-Khirod

Saturday, July 4, 2015

Hello Juby with warbler

Lets have a Hello world program through jruby and prepare a executable jar through warbler.

Let's assume jruby already installed . In my case I used jruby 1.7.8

Please create the below directory structure :

HelloWorld---|
                       |--bin--main.rb
                       |--lib--hello--hello.rb
                       |--Gemfile                      -------File
                       |--helloworld.gemspec   -------File

copy the below content to the respective file, then execute the below steps through terminal. at the end you should have a HelloWorld.jar in your project directory and follow the step number (5) to get the output.

  1. install bundler gem : gem install bundler
  2. change to the directory HelloWorld 
  3. execute bundle : $> bundle
  4. warble compiled jar
  5. java -jar HelloWorld.jar


helloworld.gemspec :

Gem::Specification.new do |s|  s.name             = 'helloworld'  s.version          = '1.0.0'  s.authors          = ['Khirod Patra']
  s.date             = '2013-07-03'  s.description      = 'Hello World'  s.email            = ['khirodpatra@gmail.com']
  s.homepage         ='khirodblog.blogspot.com/'
  s.require_paths    = ['lib','bin']
  s.files            = Dir.glob("{bin,lib}/**/*")
  s.executables   = s.files.select { |f| f =~ /^bin\// }.map{ |f| File.basename(f) }
  s.default_executable = 'bin/main.rb'  end

GemFile :

source 'https://rubygems.org'

gem 'warbler'

hello.rb :

module Hello
  class SayHello
    def hello
      puts "hello World"    end  endend

main.rb :

#!/usr/bin/env ruby
require 'rubygems'

require 'java'
my_lib = File.expand_path(File.dirname(__FILE__) + "/../lib")$LOAD_PATH.unshift(my_lib) unless $LOAD_PATH.include?(my_lib)
require 'hello/hello'
module Hello
  class Main    SayHello.new.hello
  endend

Tuesday, June 16, 2015

instant oracle 12c client on linux

1) get the below instance oracle 12c client from oracle site

  • instantclient-basic-linux.x64-12.1.0.2.0.zip
  • instantclient-sqlplus-linux.x64-12.1.0.2.0.zip
2) create a oralce_instance directory in your home directory

3) unzip both instantclient zip file in /home/xyz/oracle_instance

4) create a soft link in /usr/bin 

cd /sur/bin; sudo ln -s /home/xyz/oracle_instance/sqlplus  

5) Create a new file 

sudo vi /etc/ld.so.conf.d/oracle.conf

insert the below line and save the file
/home/xyz/oracle_instance/

Note : Oracle client instance home directory may be different in your case. So choose it accordingly.

6) sudo ldconfig


troubleshooting :

if sqlplus complain about the library libaio.so.1 , then install below library.

sudo apt-get install libaio1



that's it, now happy sqlplus  . If you want to install the oracle instant client from rpm package you need alien . Please check one of my old post.




Monday, February 23, 2015

Install oracle client in Ubuntu 14.04

Please follow these below steps to install oracle client12 in ubuntu 14.04

Here it will just install the sqlplus and it's supporting library only.

Download oracle-instance-sqlplus and oracle-instance-basic from oracle site . Please make sure to download the version as per the OS system type like 32 or 64bit.

sudo apt-get install alien
sudo alien -i 
sudo alien -i 



NOTE : it will create the .deb file and install .deb file by double clicking on the file else follow the below command to install the .deb file 
dpkg -i <.deb file>




sudo apt-get install libaio1 
sudo vi /etc/ld.so.conf.d/oracle.conf
 
update the below line in oracle.conf. Please make sure the exact path. In my case it is given below.

/usr/lib/oracle/12.1/client64/lib/
sudo ldconfig
 
Now check  if oracle installed successfully or not.
 
which sqlplus64 
OR
which sqlplus

Extra steps to manage oracle client from HOME with tnsnames.ora

cd /home
ln -s /usr/lib/oracle/12.1/client64 oracle
cd oracle
sudo mkdir -p network/admin
sudo vi tnsnames.ora
NOTE : Please add the required service string in tnsnames.ora , then save and quit the file.
vi ~/.bashrc OR vi ~/.bash_profile
export ORACLE_HOME=/home/oracle
export PATH=$PATH:$ORACLE_HOME/bin
 
that's it, and happy sqlplus
 
 

 
 

Thursday, May 29, 2014

C extension support is not enabled. [pry-stack_explorer]

If you are using pry then you may looks for better pry debugger plugins . I faced the above issue when I used to install pry-stack_explorer. The complete error you can find here :

https://www.ruby-forum.com/topic/4832612#new

In my case I am using pry-nav and pry-stack_explorer combined to debug the code. Please follow the below steps to install the above plugins.

1) install jruby-1.7.8, Export the variable JRUBY_HOME and PATH
NOTE : explicitly export this variable as we are going to use it once.
export JRUBY_OPTS=-Xcext.enabled=true

2) install ruby-1.9
NOTE : Here we need ruby-1.9 only for libraries, So you can set the --prefix at the time of
configuration and install in you specified directory.

3) create directory structure in JRUBY_HOME/lib/native/include

4) create soft link in JRUBY_HOME/lib/native/include
 ln -s RUBY_HOME/include/ruby-1.9.1/ruby ruby

5) jruby -S gem install pry-nav

6) jruby -S gem install pry-stack_explorer

that's it .

Please suggests if any body have any better tricks or idea.


Thanks
-Khirod





Tuesday, May 20, 2014

cannot load Java class jline.console.ConsoleReader

Please follow the link for more information.

https://www.ruby-forum.com/topic/4816085#new

-Khirod

Friday, April 25, 2014

eclipse icon issue in ubuntu 12.04



  1. Install gnome-desktop if it is not there 
  2. Execute the command gnome-desktop-item-edit --create-new ~/Desktop
  3. click on the icon on left top side of the pop up box and set the for icon.xpm where eclipse edittor unzipped
  4. set the application path
Now it is ready to run eclipse from your Desktop luncher.



-Khirod

Saturday, February 15, 2014

ssh login without password

1)  Install ssh on both Host , we will take as client1 and client2 . Here client1 will login to client2 through ssh without password.

2)from client1:
cd ~
ssh-keygen -t rsa

Enter file in which to save the key (/home/client1/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/kshyama/.ssh/id_rsa.
Your public key has been saved in /home/kshyama/.ssh/id_rsa.pub.
The key fingerprint is:
da:0d:08:10:8c:e6:59:2d:b0:59:8d:cf:3f:bd:70:e6 kshyama@kshyama
The key's randomart image is:
+--[ RSA 2048]----+
| ooo..+          |
|....++ o         |
|o  oo +          |
| . . . +         |
|  .   . S .      |
|       o * +     |
|      . . B .    |
|           E     |
|                 |
+-----------------+


3)cat .ssh/id_rsa.pub | ssh client2@192.168.3.20 'cat >> .ssh/authorized_keys'

Now you are done. The ssh connection will not ask any password from client1 to client2

Tuesday, January 14, 2014

[JRUBY] NameError: uninitialized constant Net::SSH::Connection::Session::JavaLang

I have gone through the work around for this issue successfully , but still not sure if it is a bug of net/ssh gem

Error Details :

NameError: uninitialized constant Net::SSH::Connection::Session::JavaLang
   const_missing at org/jruby/RubyModule.java:2642


The above error encountered when my program tried to open a new channel session. It looks for JavaLang. I just simple add a module of JavaLang which use the package of java.lang and issue resolved. i.e.


require 'java'
require 'rubygems'
require 'net/ssh'


module JavaLang
  include_package "java.lang"
end

class Testing1
   
  def testConnection()
    Net::SSH.start("myhost","user_id", :password => "password" ) do |ssh|
       puts("Connection Established")
      ssh.open_channel do |channel|
        puts("SSH Channel opened successfully")
      end
    end
  end

end



-Khirod

Monday, December 10, 2012

Network File System (NFS)

Follow the below syntax to create a Network File System. Please Note you must have the Root access to do this anyway.

Let two host A and B both can be access to each other over the network and you want to create a NFS on B from A.

Example Case:

java installed on machine A and JAVA_HOME on Host A is : /home/java/jdk1.6.0_33 . and you want to use the java on machine B with out installing it on B

ON Host B :

1) create a directory java [Note you can crteate this directory anywhere]. I am taking /mnt as parent directory , so you must be root or you have the sudo access to do so

 ~]# mkdir /mnt/java

2)open the file /etc/fstab and append the below line . Please change the parameter as per your requirements

 ~]# vi /etc/fstab

A:/home/java/jdk1.6.0_33 /mnt/java nfs defaults 0 0

A : Host name or IP address
/home/java/jdk1.6.0_33 : Path on Host A
/mnt/java                       : Path on Host B


On Host A:

1) Open the file /etc/exports and append the below line. Please change the path as per your requirements.

~]# vi /etc/exports

/home/java/jdk1.6.0_33 *(rw,sync,no_root_squash)

2)Start the nfs service. The below command will stop and start the service

 ~]# service nfs restart

3) Start portmnp service

~]# service portmap restart



Final step on Host B:

~]# mount /mnt/java


Now you are done. you can set your JAVA_HOME and PATH on Host B using the path /mnt/java.


Friday, June 22, 2012

Add Ruby Gems to your Jruby Application

In two way you can add Ruby Gems to your JRuby application.

Case 1: In this case we will take the gems for ssh connections i.e. net-ssh. So what ever the gems you want to add in your application , 1st check the required dependencies for that gems. in this case for net-ssh we required

1)jruby-openssl
2)jruby-pageant

Steps:: Case 1:-

1)download the jruby-complete-XXXX.jar file . check with below link for the respective versions.

http://jruby.org/download

you can create a jruby-complete.jar file from source too.
            a) download the jruby source from http://jruby.org/download
                Ex:-  E:\jruby-src-1.6.7.2.zip

            b) unzip it to any local directory
                 Ex:- unzip  jruby-src-1.6.7.2.zip
                         It will create a directory  jruby-1.6.7.2
            c) download and unzip ant if ant is not on your system http://ant.apache.org/bindownload.cgi
            d) set the ANT_HOME and PATH for the ant.
            e) change current directory  to the unzip jruby source directory
                   cd E:\jruby-1.6.7.2
            f) ant jruby-complete

It will create a jruby-complete.jar file which is same as if you follow to download it from the repository link http://jruby.org/download

Let your final jruby-complete.jar file in E:\jruby\jruby-complete.jar

2)  Let download and get the required gems . use the following command to do so

To get jruby-openssl:

java -jar jruby-complete-1.6.7.2.jar -S gem install -i ./jruby-openssl jruby-openssl --no-rdoc --no-ri

To get jruby-pageant:

java -jar jruby-complete-1.6.7.2.jar -S gem install -i ./jruby-pageant jruby-pageant --no-rdoc --no-ri

To Get net-ssh :

java -jar jruby-complete-1.6.7.2.jar -S gem install -i ./net-ssh net-ssh --no-rdoc --no-ri

Now you have all the gems in your current directory i.e. E:\jruby

3) Let push these gems to the jruby-complete.jar file

jar uf jruby-complete-1.6.7.2.jar -C jruby-openssl .
jar uf jruby-complete-1.6.7.2.jar -C jruby-pageant .
jar uf jruby-complete-1.6.7.2.jar -C net-ssh .

4)  Lets check if the gems pushed successfully or not

java -jar jruby-complete-1.6.7.2.jar -S gem list

*** LOCAL GEMS ***

bouncy-castle-java (1.5.0146.1)
jruby-openssl (0.7.7)
jruby-pageant (1.1.1 java)
net-ssh (2.5.2)
rake (0.8.7)
sources (0.0.1)

5)  Let's check if the gems are loading through require or not

java -jar jruby-complete-1.6.7.2.jar -S irb

irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'net/ssh'
=> true
irb(main):003:0> exit

-------------------------------End of Case 1--------------------------------------------------------------------
NOTE : you can install and push the gems in a single command also , just use them in the same command syntax with space..
--------------------------------------------------------------------------------------------------------------------
WOW that's it . now all your gems in your jar file.


Steps - Case 2:

case 2 is the traditional one.

1) follow the same step no 1 from Case1
2) now you have the jruby-complete.jar file . and your current directory is
     E:\jruby
     create a directory structure E:\jruby\lib\gems\1.8

Note : Here I used the above path for a separate the gems directory . So it is completely depends on you how you manage your path.

3) java -jar jruby-complete.jar -S install jruby-openssl jruby-pageant net-ssh --no-ri --no-rdoc -i lib/gems/1.8

 The above command will install all the required gems described in the command in the defined path . So here you can replace your destination path


4) Set the GEM_PATH

set GEM_PATH=E:\jruby\lib\gems\1.8

In Linux : export GEM_PATH=`pwd`/lib/gems/1.8

5)  Now follow the Steps No 4 and 5 from Case 1 to get the result.

That's It

------------------------------------------End of Case 2--------------------------------------------------

- Khirod







Tuesday, June 19, 2012

rvd: Unable to create transport on UDP port XXXX

2012-06-19 03:22:26 rvd: Unable to create transport on UDP port XXX. Previously created transport specified network as '192.168.XXX.15;192.168.180.255;192.168.XXX.125' which caused the send address for the port to be bound to 192.168.XXX.125, while current transport specifies network as ';;192.168.XXX.51;;' which requests the send address to be bound to 192.168.XXX.51. You cannot associate the same service parameter with two different network parameters.
./tibrvsend: Failed to initialize transport: Arguments conflict




In the above case just change the service port number and accordingly on the listener side. The above error is normal. Here the subnet is different So so the UDP port being reserved by some time . after sometime it will be released automatically.

If you do not want to wait upto release just use another service port . careful if the same port may be used by any other service. So better have a grep to /etc/services with the used port. In the most worst case just restart the RVD.




Example :

./tibrvsend -network ";;192.168.188.51" -service XXXX -daemon tcp:7500 Test.message "Hello World"

Next use
./tibrvsend -network ";;192.168.199.156" -service YYYY -daemon tcp:7500 Test.message "Hello World"

tibrvsend to different subnet

The below example will explain you, how to send the message to different subnet.

Let  a network Bcast Address : 192.168.180.255
                              System IP  : 192.168.180.15
                             Host Name : tiger100
                   RVD service port : 7190


Another Network Bcast Address: 192.168.175.255
                             System IP       :192.168.175.51
                             Host Name     : lion100
                       RVD service port : 5991

Here we are going to send the message from tiger100 to lion100

1) check on both system if rvd process is running or not. It should running . else start rvd on both
    
    ps -ef | grep 'rvd'

2) Start the rvd listener on lion100

./tibrvlisten -service 7190  -daemon tcp:7500 Test.message

3) Now send the message from tiger100

./tibrvsend -network ";;192.168.175.51" -service 7190 -daemon tcp:7500 Test.message "Hello World"

That it... Now you the message at lion100.

Friday, June 1, 2012

File.executable? does not in this environment and will return a dummy value

 warning: executable? does not in this environment and will return a dummy value

I face this warning in java5 when executing command in system("command/shell script"). as the system usually check if the shell script is executable or not.

and java5 is required anyway for my application . So did the below changes to avoid the warning.

Before : system("shell Script")
After : output=`#{command}`

Tuesday, May 29, 2012

Global variable in Ruby/JRuby

If anybody wants to create a global variable which can be access to all the ruby class and module through out the project. then follow the example given below:

$globalvariable=

class
   .
   .
   .

end


The value of the globalvariale can be access through out the ruby project.

i.e. puts($globalvariable)

NOTE: "$globalvariable=value" may be display as $globalvariable= . it is a Bug with Blogger. So read it as  "$globalvariable=value"