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 / ReadPropertiesWithGuava.java
Last active September 5, 2019 16:30
Load a properties file using Guava.
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Properties;
import com.google.common.io.ByteSource;
import com.google.common.io.Resources;
/**
* Reads a properties file and print all the key value pairs to the console.
@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
@P7h
P7h / tmux.cheat
Last active February 7, 2019 15:38 — forked from afair/tmux.cheat
========================================== ==========================================
TMUX COMMAND WINDOW (TAB)
========================================== ==========================================
List tmux ls List ^b w
New -s <session> Create ^b c
Attach att -t <session> Rename ^b , <name>
Rename rename-session -t <old> <new> Last ^b l (lower-L)
Kill kill-session -t <session> Close ^b &
@P7h
P7h / setup_spark_env.sh
Last active January 16, 2019 12:08
Download and setup [from the command line] Java, Scala, SBT and Spark on a Ubuntu machine.
### This script downloads and sets up the following binaries.
## Java: 8u91
## Scala: 2.11.8
## SBT: 0.13.11
## Spark: 1.6.1
sudo usermod -a -G sudo hduser
## Install the essential packages.
sudo apt-get install ssh zip p7zip p7zip-full multitail htop screen tmux -y # subversion git python-pip
@P7h
P7h / jdk8_download.sh
Last active November 5, 2018 14:51
JDK8 command line download script; For JDK10, please check: https://gist.github.com/P7h/9741922
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####
### Shell script to download Oracle JDK / JRE / Java binaries from Oracle website using terminal / command / shell prompt using wget / curl.
### You can download all the binaries one-shot by just providing one BASE_URL.
### Script might be useful if you need Oracle JDK on Amazon EC2 env.
### Script is updated for every JDK release.
### Features:-
# 1. Resumes a broken / interrupted [previous] download, if any.
# 2. Renames the file to a proper name with including platform info.
@P7h
P7h / jdk9_download.sh
Created July 25, 2018 19:52
JDK9 command line download script; For JDK10, please check: https://gist.github.com/P7h/9741922
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####
### Shell script to download Oracle JDK / JRE / Java binaries from Oracle website using terminal / command / shell prompt using wget.
### You can download all the binaries one-shot by just giving the BASE_URL.
### Script might be useful if you need Oracle JDK on Amazon EC2 env.
### Script is updated for every JDK release.
### Features:-
# 1. Resumes a broken / interrupted [previous] download, if any.
# 2. Renames the file to a proper name with including platform info.
@P7h
P7h / Stopwatch.scala
Created May 12, 2017 11:11
DateTime difference between 2 timestamps. Granularity from centuries to nanos.
import java.time.LocalDateTime
import scala.annotation.tailrec
object Stopwatch {
def main(args: Array[String]): Unit = {
val from = LocalDateTime.of(2001, 9, 11, 8, 46, 40, 250)
val to = LocalDateTime.now()
@P7h
P7h / toree_install.sh
Created May 21, 2018 12:48
Apache Toree intallation steps
sudo apt install screen htop ncdu multitail
conda install jupyterlab pyspark
conda install -c conda-forge jupyter_contrib_nbextensions altair vega_datasets vega3
pip install https://dist.apache.org/repos/dist/dev/incubator/toree/0.2.0/snapshots/dev1/toree-pip/toree-0.2.0.dev1.tar.gz
jupyter toree install --spark_home=~/spark-2.3.0 --user
jupyter toree install --interpreters=Scala,PySpark,SQL --user
jupyter kernelspec list
@P7h
P7h / ConEmu.xml
Last active December 12, 2017 12:50
Customized ConEmu [https://github.com/Maximus5/ConEmu] configuration as on 12th Dec, 2017.
<?xml version="1.0" encoding="utf-8"?>
<key name="Software">
<key name="ConEmu">
<key name=".Vanilla" modified="2017-12-11 20:35:09" build="171205">
<value name="StartType" type="hex" data="02"/>
<value name="CmdLine" type="string" data=""/>
<value name="StartTasksFile" type="string" data=""/>
<value name="StartTasksName" type="string" data="{Shells::cmd}"/>
<value name="StartFarFolders" type="hex" data="00"/>
<value name="StartFarEditors" type="hex" data="00"/>
@P7h
P7h / sed_log4j.sh
Last active October 26, 2017 15:21
Replaces all levels to ERROR in all the log4j.properties files on the disk
sudo find / -type f -name "log4j.properties" -exec sed -i 's/TRACE/ERROR/g' {} +
sudo find / -type f -name "log4j.properties" -exec sed -i 's/DEBUG/ERROR/g' {} +
sudo find / -type f -name "log4j.properties" -exec sed -i 's/INFO/ERROR/g' {} +
sudo find / -type f -name "log4j.properties" -exec sed -i 's/WARN/ERROR/g' {} +