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 / Java8DateTimeFormattingAndParsing.scala
Last active April 14, 2016 21:57
Formatting and parsing date and time with Java 8
import java.time._
import java.time.format.DateTimeFormatter
val date = "Sun Apr 03 05:40:58 +0200 2016"
val formatter = DateTimeFormatter.ofPattern("EE MMM dd HH:mm:ss ZZ yyyy")
val parsedDate = LocalDateTime.parse(date, formatter)
// parsedDate: java.time.LocalDateTime = 2016-04-03T05:40:58
val parsedDateTZ = ZonedDateTime.parse(date, formatter)
// parsedDateTZ: java.time.ZonedDateTime = 2016-04-03T05:40:58+02:00
@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

Keybase proof

I hereby claim:

  • I am P7h on github.
  • I am p7h (https://keybase.io/p7h) on keybase.
  • I have a public key whose fingerprint is A775 C217 20FF C0CE E9D1 E60C EFB3 9713 80D4 F9CD

To claim this, I am signing this object:

@P7h
P7h / Dockerfile
Last active September 18, 2016 11:55
Docker Image for GHC v8.0.1 and Cabal v1.24
FROM ubuntu
MAINTAINER Prashanth Babu <[email protected]>
RUN apt-get update && \
apt-get install -yqq software-properties-common screen vim && \
add-apt-repository -y ppa:hvr/ghc && \
apt-get update && \
apt-get install -yqq cabal-install-1.24 ghc-8.0.1 && \
apt-get clean && \
@P7h
P7h / Bash_command_line_shortcuts.md
Created September 13, 2016 14:44
Bash command line Shortcuts

Bash command line Shortcuts

Picked these from here

Command Editing Shortcuts

Command Note
Ctrl + a go to the start of the command line
Ctrl + e go to the end of the command line
Ctrl + k delete from cursor to the end of the command line
@P7h
P7h / Install_7zip_on_Linux.md
Last active February 24, 2025 03:23
7zip install on Linux -- Ubuntu and Fedora or CentOS / RHEL

Steps to install 7zip on Linux » Ubuntu and Fedora or CentOS / RHEL

Ubuntu

cat /etc/*release
sudo apt-get update -yqq
sudo apt-get install -yqq p7zip-full
@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' {} +
@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 / 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 / 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