Skip to content

Instantly share code, notes, and snippets.

View MarounMaroun's full-sized avatar
🎹
♫♩♬

Maroun Maroun MarounMaroun

🎹
♫♩♬
View GitHub Profile
@MarounMaroun
MarounMaroun / commit-msg.sh
Last active June 26, 2018 09:11
Add branch name to commit message githook
mkdir -p ~/.git_hooks
# make it executable
chmod a+x ~/.git_hooks/commit-msg
# ---------------------------
# vi ~/.git_hooks/commit-msg:
NAME=$(git branch | grep '*' | sed 's/* //')
DESCRIPTION=$(git config branch."$NAME".description)
echo "$NAME"': '$(cat "$1") > "$1"
@MarounMaroun
MarounMaroun / config
Created September 11, 2017 13:47
Terminator custom configurations
[global_config]
enabled_plugins = LaunchpadCodeURLHandler, APTURLHandler, LaunchpadBugURLHandler
[keybindings]
broadcast_all = <Primary>g
broadcast_group = <Primary><Shift>underscore
broadcast_off = <Primary><Shift>g
close_window = <Primary><Shift>q
move_tab_left = <Shift><Alt>Page_Down
move_tab_right = <Shift><Alt>Page_Up
next_tab = <Alt>2
@MarounMaroun
MarounMaroun / install_mongo.sh
Created January 16, 2018 06:35
MongoDB installation
read -p "What version you want to install? " version
brew install mongo@$version
brew install mongod
sudo mkdir -p /data/db
sudo chmod -R go+w /data/db
echo "Done! Run \"mongod\" to start the database"
@MarounMaroun
MarounMaroun / ByNameValue.scala
Created December 28, 2017 08:50
Call by name VS call by value in Scala
// defining a simple function that returns the current time
def getTime = System.currentTimeMillis
// defining a function, by NAME, that prints two times: now and one second later
def getTimeByName(f: => Long) = { println(f); Thread.sleep(1000); println(f)}
// defining it again, but this time, by VALUE
def getTimeByValue(f: Long) = { println(f); Thread.sleep(1000); println(f)}
getTimeByName(getTime)
@MarounMaroun
MarounMaroun / instance_types_extractor.py
Last active December 18, 2017 21:45
AWS instance types extractor
from lxml import etree
import urllib
web = urllib.urlopen("https://aws.amazon.com/ec2/instance-types")
s = web.read()
html = etree.HTML(s)
tr_nodes = html.xpath('//*[@id="aws-page-content"]/div/div/main/section/div[2]/div[43]/div/table/tbody/tr')
@MarounMaroun
MarounMaroun / get_repose.sh
Created November 25, 2017 09:15
Clone all of your public repositories
repos=$(curl -s https://api.github.com/users/{USER}/repos?per_page=1000 | grep -oP "(?<=clone_url\": \").*(?=\")")
echo "$repos" | while read line ; do
git clone $line
done
@MarounMaroun
MarounMaroun / SingletonExample.scala
Created November 21, 2017 05:41
Scala singleton example using object
object Singleton {
private var i = 0
def create(): Int = {
i += 1
i
}
}
Singleton.create() // 1
@MarounMaroun
MarounMaroun / ExampleClass.scala
Created November 20, 2017 11:41
Difference between "case class" and "class" in Scala
/**
* Case classes define a factory method for creating instances:
* - lines 24-25 don't have the "new" keyword.
*
* Case classes generate implementations of toString, hashCode and quals:
* - see output in lines 24-27
*
* Much more differences, like immutability and generation of companion object.
*
* Note that in order to run the snippet below, use "scala" directly, don't attempt to compile with "scalac".
@MarounMaroun
MarounMaroun / install_java.sh
Last active November 19, 2017 05:41
Java 8/9 installation in Ubuntu
# add PPA
sudo add-apt-repository ppa:webupd8team/java
# install the installer script
sudo apt update; sudo apt install oracle-java8-installer
# optional - set env vars
sudo apt install oracle-java8-set-default
@MarounMaroun
MarounMaroun / SO.md
Last active October 19, 2017 13:25
Why Stack Overflow is part of my daily routine

"It is literally true that you can succeed best and quickest by helping others to succeed" - Napoleon Hill

If you've ever been interested in programming or anything related to, and been around the net long enough, you've came across Stack Overflow, accidentally or on purpose.

What is Stack Overflow?

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's built and run by you as part of the Stack Exchange network of Q&A sites. With your help, we're working together to build a library of detailed answers to every question about programming

It was almost four years ago when I asked my first question in Stack Overflow (as a guest), got down-voted and my question was closed. Back then, I didn't know why was that; all what I asked for was a solution for my homework, and by saying "solution" I mean a full solution. I didn't expect comments like: