Skip to content

Instantly share code, notes, and snippets.

View P7h's full-sized avatar

Prashanth Babu P7h

  • London, UK
View GitHub Profile
@P7h
P7h / Maven_Phases__Commands.txt
Created March 24, 2014 15:43
Maven Important commands and Lifecycle phases.
Lifecycle Phase Description
validate Validates whether project is correct and all necessary information is available to complete the build process.
initialize Initializes build state, for example set properties
generate-sources Generate any source code to be included in compilation phase.
process-sources Process the source code, for example, filter any value.
generate-resources Generate resources to be included in the package.
process-resources Copy and process the resources into the destination directory, ready for packaging phase.
compile Compile the source code of the project.
process-classes Post-process the generated files from compilation, for example to do bytecode enhancement/optimization on Java classes.
generate-test-sources Generate any test source code to be included in compilation phase.
@P7h
P7h / Primes.java
Last active August 29, 2015 13:59
Trivia: Generate primes between 1 and 100 million with Hadoop MapReduce job. Inspired by https://gist.github.com/krishnanraman/6346307.
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
@P7h
P7h / CreateMissingFiles.py
Created May 12, 2014 16:44
Python utility to create missing tsv files [numbered 1 to 78] in a directory.
import os
folder_name = 'D:/issue/'
for i in range(1, 79):
fileName = folder_name + str(i) + ".tsv"
if not os.path.isfile(fileName):
with open(fileName, 'w') as f:
f.write('word\tcount\n')
f.close()
@P7h
P7h / RenameFileInSubFolder.py
Last active April 15, 2016 02:14
Renaming files in many sub-folders. Requirement: There is a huge directory list which has many sub-directories and one file in each sub-directory, which has to be renamed as sub-directory name with the original extension. Last sub-directory name is always 8 chars. After renaming is done, it has to be moved to a different folder. Wrote a small Py…
import os
# Current working directory where files and folders are present.
rootDir = os.getcwd()
# Destination directory to copy files.
destinationDir = 'D:/GBR/'
# Walk thru the directories in this root directory.
for dirName, subdirList, fileList in os.walk(rootDir):
@P7h
P7h / ShutFirewall.sh
Last active August 29, 2015 14:01
Turn off the firewall on a Linux machine
sudo service iptables save
sudo service iptables stop
sudo chkconfig iptables off
# Ubuntu
sudo ufw status
sudo ufw off
@P7h
P7h / show-ip-address.sh
Last active December 21, 2015 15:48
For showing IP Address before the login prompt on Ubuntu env. Copy the following script to /etc/network/if-up.d/ and /etc/network/if-post-down.d/ folders. And don’t forget to mark them as executables.
# This shell script displays hostname and IP Address of the Ubuntu machine before the login prompt.
# Add this file to '/etc/network/if-up.d/' and '/etc/network/if-post-down.d/' folders and mark them as executables.
# Display Ubuntu default information [the current version of Ubuntu].
cat /etc/issue.net > /etc/issue
# Display the hostname.
hostname >> /etc/issue
# Display the IP Address of eth0.
@P7h
P7h / .tmux.conf
Last active March 7, 2017 02:26
My tmux conf
# List of plugins
# Supports `github_username/repo` or full git URLs
set -g @tpm_plugins " \
tmux-plugins/tpm \
tmux-plugins/tmux-sensible \
tmux-plugins/tmux-resurrect \
"
# Other examples:
# github_username/plugin_name \
@P7h
P7h / kill_sessions__tmux_screen.sh
Last active April 15, 2016 02:14
Kill all tmux sessions and screen sessions.
# Not advisable. Do this ONLY if you understand what you are doing!
# This will terminate all your tmux or screen sessions, if you have any work yet to be saved, you will not be able to recover if you do this.
# Kill all the tmux sessions
tmux ls | grep : | cut -d. -f1 | awk '{print substr($1, 0, length($1)-1)}' | xargs kill
# Kill all the detached screen sessions
screen -ls | grep Detached | cut -d. -f1 | awk '{print $1}' | xargs kill
@P7h
P7h / tmux__CentOS__build_from_source.sh
Last active October 11, 2025 01:02
tmux 2.0 and tmux 2.3 installation steps for Ubuntu. Or build from tmux source v2.5 for Ubuntu and CentOS.
# Steps to build and install tmux from source.
# Takes < 25 seconds on EC2 env [even on a low-end config instance].
VERSION=2.7
sudo yum -y remove tmux
sudo yum -y install wget tar libevent-devel ncurses-devel
wget https://github.com/tmux/tmux/releases/download/${VERSION}/tmux-${VERSION}.tar.gz
tar xzf tmux-${VERSION}.tar.gz
rm -f tmux-${VERSION}.tar.gz
cd tmux-${VERSION}
@P7h
P7h / tmux-cheatsheet.md
Last active February 7, 2019 15:41 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname