Skip to content

Instantly share code, notes, and snippets.

Prashanth Babu P7h

Block or report user

Report or block P7h

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
@P7h
P7h / jdk9_download.sh
Created Jul 25, 2018
JDK9 command line download script; For JDK10, please check: https://gist.github.com/P7h/9741922
View jdk9_download.sh
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####
### 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 / toree_install.sh
Created May 21, 2018
Apache Toree intallation steps
View toree_install.sh
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 / jdk8_download.sh
Last active Nov 5, 2018
JDK8 command line download script; For JDK10, please check: https://gist.github.com/P7h/9741922
View jdk8_download.sh
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####
### 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 / VBox_Share.sh
Created Aug 17, 2017
Share folders between Guest and Host OS with Virtual Box.
View VBox_Share.sh
# Create a shared folder "Share" in the Host OS through the GUI.
# Run the following in the Virtual Box Guest OS.
sudo usermod -aG vboxsf <<current_user>>
mkdir ~/share
sudo mount -t vboxsf -o uid=$UID,gid=$(id -g) Share ~/share
@P7h
P7h / zeppelin_docker_image.sh
Last active Aug 31, 2017
Zeppelin official Docker image download and configure for O'Reilly Spark 2.1 course
View zeppelin_docker_image.sh
# Docker mounts the user's home directory.
# We will download the course notebooks and data into a folder in the home directory and mount it with out Docker image.
mkdir ~/zepp; cd ~/zepp
mkdir -p notebooks logs data
wget -c https://codeload.github.com/adbreind/spark-zeppelin-17-1/zip/master -O spark-zeppelin-17-1-master.zip
unzip spark-zeppelin-17-1-master.zip
mv spark-zeppelin-17-1-master/data/* data/
mv spark-zeppelin-17-1-master/notebooks/* notebooks/
rm -rf spark-zeppelin-17-1-master.zip spark-zeppelin-17-1-master
@P7h
P7h / Stopwatch.scala
Created May 12, 2017
DateTime difference between 2 timestamps. Granularity from centuries to nanos.
View Stopwatch.scala
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 / FizzBuzz.hs
Created Feb 4, 2017
FizzBuzz in Haskell
View FizzBuzz.hs
-- FizzBuzz in Haskell
fizzbuzz :: Int -> String
fizzbuzz n = if fb /= ""
then fb
else show n
where fb = fizz n ++ buzz n
fizz:: Int -> String
@P7h
P7h / FizzBuzz.scala
Created Feb 4, 2017
FizzBuzz in Scala
View FizzBuzz.scala
object FizzBuzz {
def main(args: Array[String]) {
(1 to 30) map fizzbuzz map println
}
case class MultipleOf(n: Int) {
def unapply(x: Int): Option[Int] = {
if(x % n == 0) {
Some(x/n)
} else {
None
@P7h
P7h / week_number.py
Last active Feb 4, 2017
Current week# using Python
View week_number.py
import datetime
year,week_num,day_of_the_week = datetime.datetime.now().isocalendar()
print year,week_num,day_of_the_week
@P7h
P7h / sed_log4j.sh
Last active Oct 26, 2017
Replaces all levels to ERROR in all the log4j.properties files on the disk
View sed_log4j.sh
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' {} +
You can’t perform that action at this time.