Skip to content

Instantly share code, notes, and snippets.

View sathish-io's full-sized avatar

Sathish Kandasamy sathish-io

View GitHub Profile
@sathish-io
sathish-io / Linux sudo no password
Created November 10, 2015 03:23
Linux sudo no password
Edit /etc/sudoers file add below, where <username> is the user name to be enabled
<username> ALL=(ALL:ALL) NOPASSWD: ALL
@sathish-io
sathish-io / SBT project setup tips
Last active July 25, 2016 22:26
SBT project setup tips
Run Spark Application from SBT console:
----------------------------------------
run-main -Dspark.master=local[*] com.greenline.data.spark.app.CollegeDataIndexerSparkApp
Add Eclipse plugin support:
-----------------------------
in project/plugins.sbt add,
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.5.0")
Then run 'sbt eclipse' or 'activator eclipse'
@sathish-io
sathish-io / 0_reuse_code.js
Last active August 29, 2015 14:26
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@sathish-io
sathish-io / Kafka setup commands
Created April 10, 2015 20:35
Kafka setup commands
Home: /Users/skandasa/installs/kafka_2.10-0.8.2.0
1) start a ZooKeeper server
bin/zookeeper-server-start.sh config/zookeeper.properties
binding to port 0.0.0.0/0.0.0.0:2181
2) Start brokers
a) bin/kafka-server-start.sh config/server.properties
- starts with port 9092
b) bin/kafka-server-start.sh config/server-1.properties
@sathish-io
sathish-io / Spring boot command line arguments
Created February 24, 2015 06:40
Spring boot command line arguments
java -jar app.jar --server.port=8180 --debug --spring.profiles.active=production --logging.file=myapp.log --logging.path=./
@sathish-io
sathish-io / logback.xml
Created February 24, 2015 06:25
logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true">
<appender name="consoleAppender" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<charset>UTF-8</charset>
<Pattern>%d %-4relative [%thread] %-5level %logger{35} - %msg%n</Pattern>
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
@sathish-io
sathish-io / Sample code to do HTTP Post using Apache HTTP Client Library
Created February 22, 2015 08:20
Sample code to do HTTP Post using Apache HTTP Client Library
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
@sathish-io
sathish-io / Simple JMS Client without JNDI lookup for IBM MQ
Created February 20, 2015 20:51
Simple JMS Client without JNDI lookup for IBM MQ
import javax.jms.Connection;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
AWK script to get min, max, sum, average, standard deviation for numbers:
cat data.txt | awk -F ":" 'BEGIN {max = 0; min = 999999; sum = 0; sumsq = 0} { x= ($NF + 0); sum += x; sumsq += x*x; if(x > max)max = x; if(x < min) min = x} END { print "Min: ", min, " Max: ",max, " Sum: ", sum, " Average: ", sum/NR , " Std Dev: ", sqrt(sumsq/NR - (sum/NR)^2) }'
Assume you have data.txt that has following data set,
2
3
6
8
11
@sathish-io
sathish-io / Basic postgresql commands
Created September 3, 2014 17:23
Basic postgresql commands
Basic postgresql commands:
\l - to list all database.
\db - to list all tables in a db.
\d <tablename> - to describe a table
Create new database