Posts

Connect js client to elasticsearch behing nginx

Reverse proxy for elasticsearch and kibana nginx setup server {   listen 8080;   server_name XXXXXXXX;    location / {      return 301 /elasticsearch/;    }    location /elasticsearch/ {      proxy_pass http://127.0.0.1:9500/;      proxy_redirect http://localhost:9500 /elasticsearch/;      auth_basic "Elasticsearch Authentication";      auth_basic_user_file /etc/elasticsearch/user.pwd;     }   location /kibana/ {       proxy_pass http://127.0.0.1:5601/;       proxy_redirect http://127.0.0.1:5601/ /kibana/;     } } Connect js client to elasticsearch behing nginx var elasticsearch = require('elasticsearch');  host =  {     protocol: 'http',     host: 'XXXXXXXX',     port: 8080,     path: '/elastics...

sending an email in nodejs

/****To send a mail  ** steps to follow 1. get email server details 2. create a smtp transport connection 3. send a mail via connection 4. close connection **/ var fs = require('fs'); var nodemailer = require('nodemailer'); //Mail server details var host = ''; var port = ''; var ssl = false; var userName = ''; var password = ''; //Generic email transport connection var getMailTransportCon = function() {     var smtpoptions = {         host: host,         port: port,         secureConnection: ssl,         auth: {             user: userName,             pass: password         }     };     //Create a mail transport connection     var mailTranspo...

Phantom js tutorial

Phantomjs is very useful tool for taking screenshot of the webpages. To take a screenshot of the simple page webpage. var phantom = require('phantom'); /***take screenshot of url**/ var options = {     path: "/phantom/bin/" }; phantom.create(function(ph) {     ph.createPage(function(page) {         page.open("http://www.google.com", function(status) {             console.log("opened page? ", status);             page.evaluate(function() {                 return document.title;             }, function(result) {                 console.log('Page title is ' + result);        ...

Git tutorials

To install git sudo apt-get update sudo apt-get git-core To check the version of git  git --version To setup Git configuration 1. Git initialize :-    git init 2. check for git status :-    git status 3. Add user name :    git config --global user.name "email@guidanz.com" 4. Add email id for user :-    git config --global user.email email@guidanz.com 6. Add git  repository :-    git remote add origin https://github.com/try-git/try_git.git 7. Clone repository :-    git clone  https://github.com/try-git/try_git.git Set proxy settings in git  git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080  git config --global https.proxy https://proxyuser:proxypwd@proxy.server.com:8080 Remove proxy  git config --global --unset http.proxy  git config --global --unset https.proxy Create a new project Assume that we have to create new project under...

Flames program

Today i tried to  write flames program in java. package com.flames.app; import java.util.Scanner; public class Main { public static void main(String args[]){ Scanner scanner = new Scanner(System.in); System.out.println("Enter your name :"); String first = scanner.next(); System.out.println("Enter your partner name :"); String second = scanner.next(); System.out.println(first + second); int points = getPoints(first , second); String res= flames(points); char result=res.charAt(0); switch(result){ case 'f': System.out.println(second+" is ur Friend"); break; case 'l': System.out.println(second+" is ur Love"); break; case 'a': System.out.println(second+" is ur Affection"); break; case 'm': System.out.println("u r going to marry "+ second); break; case 'e': System.out.println(second + " is ur Ene...

Kibana 4 Installation and Run as a service in ubuntu

Download and install kibana4 To download kibana 4 wget https://download.elasticsearch.org/kibana/kibana/kibana-4.0.1-linux-x64.tar.gz Extract and Rename kibana tar -xvzf kibana-4.0.1-linux-x64.tar.gz sudo mv kibana-4.0.1-linux-x64 kibna-4 To run kibana *Run bin/kibana on unix, or bin\kibana.bat on Windows. *Visit http://localhost:5601 To set kibana 4 as a service 1. Create a file in /etc/init.d/kibana 2. Add kibana.txt  contents into  file 3 . Give permissions to    sudo chmod 755 /etc/init.d/kibana 4. Update kibna in update-rc.d     sudo update-rc.d kibana 5. To start kibana as a service     sudo service kibana start 6. Disable autostart for a tomcat service     update-rc.d kibana disable Kibana.txt #!/bin/sh #Change kibana path as per your config KIBANA_EXEC="/opt/kibana/bin/kibana" LOG_FILE="/var/log/kibana/log" PID_FILE="/var/run...

Proxy setting in java

3 properties can set in http,https and ftp proxy handler Http proxy in java 1. http.proxyHost: the host name of the proxy server 2. http.proxyPort: the port number, the default value being 80. 3. http.nonProxyHosts:a list of hosts that should be reached directly, bypassing the proxy. Add http proxy when run main class 1. $ java -Dhttp.proxyHost=webcache.example.com GetURL 2. $ java -Dhttp.proxyHost=webcache.example.com -Dhttp.proxyPort=8080 -Dhttp.nonProxyHosts=”localhost|host.example.com” GetURL Add https proxy when run main class 1. $ java -Dhttps.proxyHost=webcache.example.com GetURL 2. $ java -Dhttps.proxyHost=webcache.example.com -Dhttps.proxyPort=8080 -Dhttp.nonProxyHosts=”localhost|host.example.com” GetURL Add http proxy in java code //Set the http proxy to webcache.example.com:808 0 System.setProperty("http.proxyHost", "webcache.example.com"); System.setProperty("http.proxyPort", "8080"); System.setProperty("...