Posts

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