Navigation Menu

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 / 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 / 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 / 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 / VBox_Share.sh
Created August 17, 2017 22:13
Share folders between Guest and Host OS with Virtual Box.
# 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 August 31, 2017 07:58
Zeppelin official Docker image download and configure for O'Reilly Spark 2.1 course
# 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 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 / FizzBuzz.hs
Created February 4, 2017 15:50
FizzBuzz in Haskell
-- 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 February 4, 2017 15:49
FizzBuzz in 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 February 4, 2017 14:58
Current week# using Python
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 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' {} +