Posts

How to increase Elasticsearch Shard recovery Speed

To Increase Shard recovery speed do this: Increase node recovery speed PUT http://es:9200/_cluster/settings { "persistent" : { "indices.recovery.max_bytes_per_sec": "200mb", "indices.recovery.max_concurrent_file_chunks": 5, "cluster.routing.allocation.node_concurrent_recoveries" : 5 } } Links: https://www.elastic.co/guide/en/elasticsearch/reference/current/shards-allocation.html https://www.elastic.co/guide/en/elasticsearch/reference/current/recovery.html

Shell Script to SSH into servers

This is a simple script that can ssh into a server by typing the password for you. Filename: login #!/usr/bin/expect eval spawn ssh username@servername expect "assword:" send "server_password\r" interact # to run the script # ./login In this below script you can pass arguments to the shell script Filename: login #!/usr/bin/expect set num [lindex $argv 0]; eval spawn ssh username@servername-$num expect "assword:" send "server_password\r" interact # make sure to give executable permission to script. chmod +x login # to run the script and login to server-01. ./login 01 Now add the script path to your .bashrc file as alias, so that you can access this script from any path. # vi ~/.bashrc alias login='/path/to/script/file/login' After updating the .bashrc file, you will have to source. source ~/.bashrc Now call the script from anywhere in your shell. login 01 Enjoy!!!

How to install Ruby 2.X and Rails 5.X using RVM

The best way to install Ruby on Rails is using RVM in Linux. Advantages of RVM, 1. You can shift between multiple versions of Ruby easily. 2. You don't have to worry about install Ruby dependencies. RVM install will take care of installing them. Some of the ruby dependencies are : gawk, autoconf, automake, bison, libffi-dev, libgdbm-dev, libncurses5-dev, libsqlite3-dev, libtool, libyaml-dev, pkg-config, sqlite3, zlib1g-dev, libgmp-dev, libreadline6-dev, libssl-dev 3. Easily upgrade Ruby version and try out a latest version to make sure your project works with the latest Ruby. If something breaks, changing the version is easy. 4. Delete unwanted Ruby version anytime :) Installation steps. Step 1. Install RVM Source : https://rvm.io/rvm/install $ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB \curl -sSL https://get.rvm.io | bash -s stable $ source /etc/profile $ source ~/.rvm/scri...

Getting started with Python Flask application with MVC structure

I have added a MVC structure and getting started with Python flask application in my Github.  I will continue to contribute to this repository with Database connections and JWT Authentication. Lets get started with Python and Flask :) Here is the Github link for my project. https://github.com/srikanthjeeva/python-flask-getting-started Structure your Flask application like a Rails Application. I'm a Rails developer. I like the way a Rails application is structured and I wanted to implement the similar kind of structure for a Python Flask web Application. Flask by default will not give you this structure. So make use of the getting started with Python flask repository above. The Code structure will look like this: python-flask-getting-started/ |-- app | |-- config.py | |-- controllers | | |-- hello_controller.py | | |-- __init__.py | |-- helpers | | |-- common_helpers.py | | |-- __init__.py | |-- __init__.py | |-- models | | ...

Converting JSON to LCOV (infofile)

Wrote a small NPM module that converts JSON to LCOV data https://github.com/srikanthjeeva/hitmap_json_to_lcov

Install Cpanm module error : No such file or directory opening compressed index

I got this error while installing Rest client perl module $ HOME=/tmp /home/perl/5.10/bin/cpanm REST::Client ! Finding REST::Client on cpanmetadb failed. ! cannot open file '/tmp/.cpanm/sources/http%www.cpan.org/02packages.details.txt.gz': No such file or directory opening compressed index ! Couldn't find module or a distribution REST::Client Solution: The problem is because of "LWP::Protocol::https" module. Removing the directory worked for me. $ cd /perl_installed_path/perl/5.10/lib/site_perl/5.10.1 $ rm –rf LWP* or try with option "--no-lwp" cpanm REST::Client --no-lwp

Error while installing Perl 5.10.1

a -Wdeclaration-after-statement -Wendif-labels -Wc++-compat cc -fstack-protector -L/usr/local/lib -o miniperl \ gv.o toke.o perly.o pad.o regcomp.o dump.o util.o mg.o reentr.o mro.o hv.o av.o run.o pp_hot.o sv.o pp.o scope.o pp_ctl.o pp_sys.o doop.o doio.o regexec.o utf8.o taint.o deb.o universal.o xsutils.o globals.o perlio.o perlapi.o numeric.o mathoms.o locale.o pp_pack.o pp_sort.o \ miniperlmain.o opmini.o perlmini.o pp.o: In function `Perl_pp_pow': pp.c:(.text+0x2d79): undefined reference to `pow' pp.o: In function `Perl_pp_modulo': pp.c:(.text+0x3b22): undefined reference to `floor' pp.c:(.text+0x3b58): undefined reference to `floor' pp.c:(.text+0x3b90): undefined reference to `fmod' pp.o: In function `Perl_pp_atan2': pp.c:(.text+0x8985): undefined reference to `atan2' pp.o: In function `Perl_pp_sin': pp.c:(.text+0x8b22): undefined reference to `sin' pp.o: In function `Perl_pp_int': pp.c:(.text...

How to place Perl modules in non-standard locations and use it

If this is the project structure, /home/directory/lib -- Libary2.pm /home/directory/project -- file1.pl -- file2.pl -- Libary1.pm In `file1.pl`, we can include both libraries by, use lib '/home/directory/project'; use lib '/home/directory/lib'; or So in `file1.pl`, #include both directory at once, use lib qw( /home/directory/project /home/directory/lib ); use Libary1; use Libary2; `file2.pl`,will have the same use lib qw( /home/directory/project /home/directory/lib ); use Libary1; use Libary2; The above code is good for 1 or 2 files. But if there are 10+ perl files, we have to include the same lib path in all files. If the library path changes, we had to change all files with the correct path name. So what I did was to have 1 module `config/LibPaths.pm` that will have the paths, and all files will include the module. lib -- Libary2.pm project -- file1.pl -- file2.pl -- Libary1.pm config -- LibPaths.pm ...

How to private chat using node.js and socket.io

Create a room with conversation_id and make users to subscribe to that room, so that you can emit a private message to that room it by, client ------ var socket = io.connect( 'http://ip:port' ); socket.emit( 'subscribe' , conversation_id); socket.emit( 'send message' , { room : conversation_id, message : "Some message" }); socket.on( 'conversation private post' , function (data) { //display data.message }); Server ------- socket.on( 'subscribe' , function (room) { console.log( 'joining room' , room); socket.join(room); }); socket.on( 'send message' , function (data) { console.log( 'sending room post' , data.room); socket.broadcast.to(data.room).emit( 'conversation private post' , { message : data.message }); }); Here is my Stackoverflow answer : http : //stackoverflow.com/a/23623724/453486

How to return Boolean values from Perl dancer

Took few minutes to figure this out

How to setup Elasticsearch Custer in Centos

I have followed these steps in order to setup Elastic search in production. # OS Requirements: Centos 6+ & Java 1.8+ Step1: ------ ------ Installing Java --------------- Download JDK from : http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html tar xzvf jdk.tar.gz sudo mkdir /usr/local/java sudo mv jdk1.8.0_45 /usr/local/java/ sudo ln -s /usr/local/java/jdk1.8.0_45 /usr/local/java/jdk export PATH="$PATH:/usr/local/java/jdk/bin" export JAVA_HOME=/usr/local/java/jdk1.8.0_91/jre sudo sh -c "echo export JAVA_HOME=/usr/local/java/jdk1.8.0_91/jre >> /etc/environment" Step2: ----- ----- Installing Elasticsearch ------------------------ wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/rpm/elasticsearch/2.3.3/elasticsearch-2.3.3.rpm sudo rpm -ivh elasticsearch-2.3.3.rpm Step 3: ------- ------- Configure Elasticsearch ----------------------- sudo vi /etc/elasticsearch/elasticsearch...

How to disable Full text search in ElasticSearch

Elastic search will index every field and every word within a value. For Example: Document 1 has : "text": "Hello World" Document 2 has : "text": "Hello Srikanth" ElasticSearch by default will create many indexes and in that the 3 index would be, ["Hello", "World", "Srikanth"] In some case we want to disable the Full text search, So that we can aggregate by that value. For Example: Document 1 has : "filepath": "/home/srikanth/1.c" Document 2 has : "filepath": "/home/srikanth/2.c" By default, ElasticSearch will index these documents by ["home", "srikanth, ".c"] , So at the time of aggregating with the path, these values will mess up the aggregated document count. So we have to tell ElasticSearch, not to index the data by By this we tell ElasticSearch, that we will always search by the full string and not by sub-strings.

How to allocate memory for Node.js server

Sometimes while making heavy calculations it is possible that node.js runs out of memory and throws this error " FATAL ERROR- JS Allocation failed – process out of memory"   By default node.js occupies 512MB RAM in a 32 bit machine and 1.4GB RAM in a 64bit machine This is how we can increase it. 

How to make Grid text selectable in DHTMLX ?

Just adding this to Grid configuration worked! grid.entBox.onselectstart = function(){ return true; }; Reference : http://forum.dhtmlx.com/viewtopic.php?f=2&t=18963

How to make https GET request with Basic Auth in Ruby

DHTMLX Grid - Load data from server with Pagination

These codes will help for Dynamic loading of data with Pagination in DHTML Grid 

Adding a pointer border to a div using CSS3

Image
Adding a pointer border to a div using CSS3

Making Will Paginate Ajax + Rails 3

1. Create a helper file : app / helpers / remote_link_pagination_helper.rb module RemoteLinkPaginationHelper   class LinkRenderer < WillPaginate::ActionView::LinkRenderer     def link(text, target, attributes = {})       attributes['data-remote'] = true       super     end   end end 2. In the View File where pagination links come, add this line. (@people is the array to paginate) will_paginate @people, :renderer => 'RemoteLinkPaginationHelper::LinkRenderer' Now the links must work with Ajax

Making a http/https post request under a proxy

Here is my post on how to make a https call. http://srikanthjeeva.blogspot.in/2010/06/making-httphttps-post-request.html Spent a long time in figuring out how to send a https request under a proxy Here is how it is, require 'net/http' require 'net/https' require 'uri' uri  = URI('https://IP/api/V1/USERS') proxy_class = Net::HTTP::Proxy(PROXY_ADDRESS, PROXY_PORT, USERNAME, PASSWORD) proxy_class.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https', :verify_mode => OpenSSL::SSL::VERIFY_NONE) { |http|   request = Net::HTTP::Get.new uri.request_uri   response = http.request request   puts response.body } Hope this helps. Thanks!
Image
Ruby Conference Pune, India - March 24, 25 - 2012