Skip to content

Instantly share code, notes, and snippets.

View mehikmat's full-sized avatar
:octocat:

Hikmat Dhamee mehikmat

:octocat:
View GitHub Profile
@mehikmat
mehikmat / count.sh
Created February 26, 2014 13:36
Hadoop commnad to run bash script in hadoop cluster-This script counts the number of lines in input file and writes count to output file
#!/bin/sh
# 's_\^\*~_\n_g' is the line delimiter in input file replace with yours
sed 's_\^\*~_\n_g'| wc -l
@mehikmat
mehikmat / parseCmdInBetterway
Last active September 20, 2018 08:09
Parsing bash/shell command line options using getopts
#!/bin/bash
usage()
{
cat << EOF
usage: $0 options
This script can download 64 or 65 version centos.
OPTIONS:
-h Show the help and exit
private static void setNumMappers(int numNodes) {
String mapred_side_xml_path = "/opt/hadoop-2.3.0-cdh5.0.1/etc/hadoop/mapred-site.xml";
try {
DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
domFactory.setIgnoringComments(true);
DocumentBuilder builder = domFactory.newDocumentBuilder();
Document doc = builder.parse(new File(mapred_side_xml_path));
NodeList nodes = doc.getElementsByTagName("configuration");
What is web Session?
--------------------
- An abstract concept to represent a series of HTTP requests and responses
between a specific web browser and server. HTTP doesn't support the
notion of a session.
- A session's data is stored on the server (only 1 session per client)
- Sessions are often built on top of cookies.
- The only data the client stores is a cookie holding a unique session ID
- And on each page request, the client sends its session ID cookie, and the
server uses this to find and retrieve the client's session data
@mehikmat
mehikmat / protobuff_install.sh
Created May 21, 2015 03:41
Protobuff installation in linux
sudo apt-get remove protobuf-compiler
sudo ldconfig
sudo apt-get install g++
g++ --version
wget http://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz
tar xzf protobuf-2.5.0.tar.gz
cd protobuf-2.5.0
./configure
make
sudo make install
@mehikmat
mehikmat / how to run java hello world app
Created May 8, 2015 08:17
This gist contains the very simple instructions to run java application from command line
First make java jar containing your all code.
Then got to terminal
$ cd project_root_dir/target
$ java -cp ./jar_file.jar com.main_class_name param_to_main_class [if jar doesn't contain manifest file]
$ java -jar jar_file.jar [if jar contains manifest file]
@mehikmat
mehikmat / UpdateFile.sh
Created March 2, 2014 13:25
Bash script to find and replace texts inside a file
...............
..................
#### Function to find and replace a text inside file using bash
updateLateCommandURLInPreseedFile(){
echo "[INFO]:: Updating late command url in pressed.cfg file**************"
echo ""
cat preseed.cfg | sed 's_${IPADDR}_'"$IP"'_g' > temp.cfg
cat temp.cfg > preseed.cfg
rm temp.cfg
@mehikmat
mehikmat / First100PrimeGen.java
Created February 15, 2014 11:03
Java code to generat any first 100 prime numbers
package com.hk.prime;
import java.util.Scanner;
public class First100Prime {
int flag;
int first;
public First100Prime() {
@mehikmat
mehikmat / FirstPDFDoc.java
Created February 14, 2014 20:03
PDF document generation using iText framework in Java
package com.test;
import java.awt.Color;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;