Skip to content

Instantly share code, notes, and snippets.

Hikmat Dhamee mehikmat

Block or report user

Report or block mehikmat

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View setNumMappersDynamically
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");
View web_stuffs
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
Protobuff installation in linux
View protobuff_install.sh
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
This gist contains the very simple instructions to run java application from command line
View how to run java hello world app
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 / parseCmdInBetterway
Last active Sep 20, 2018
Parsing bash/shell command line options using getopts
View parseCmdInBetterway
#!/bin/bash
usage()
{
cat << EOF
usage: $0 options
This script can download 64 or 65 version centos.
OPTIONS:
-h Show the help and exit
@mehikmat
mehikmat / UpdateFile.sh
Created Mar 2, 2014
Bash script to find and replace texts inside a file
View UpdateFile.sh
...............
..................
#### 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 / count.sh
Created Feb 26, 2014
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
View count.sh
#!/bin/sh
# 's_\^\*~_\n_g' is the line delimiter in input file replace with yours
sed 's_\^\*~_\n_g'| wc -l
@mehikmat
mehikmat / First100PrimeGen.java
Created Feb 15, 2014
Java code to generat any first 100 prime numbers
View First100PrimeGen.java
package com.hk.prime;
import java.util.Scanner;
public class First100Prime {
int flag;
int first;
public First100Prime() {
@mehikmat
mehikmat / FirstPDFDoc.java
Created Feb 14, 2014
PDF document generation using iText framework in Java
View FirstPDFDoc.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;
You can’t perform that action at this time.