Skip to content

Instantly share code, notes, and snippets.

Maroun Maroun MarounMaroun

Block or report user

Report or block MarounMaroun

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
@MarounMaroun
MarounMaroun / install-2.23.0.sh
Created Aug 17, 2019
Git 2.23.0 installation
View install-2.23.0.sh
#!/bin/bash
curl -O https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.23.0.tar.gz
tar -xvf git-2.23.0.tar.gz
cd git-2.23.0/
./configure
make && make install
cp git /usr/local/bin/git
View gist:aa0eab5e975081df1601d27a87180a69
{
"contexts": {
"application-1": {
"beans": {
"spring.transaction-org.springframework.boot.autoconfigure.transaction.TransactionProperties": {
"prefix": "spring.transaction",
"properties": {}
},
"management.trace.http-org.springframework.boot.actuate.autoconfigure.trace.http.HttpTraceProperties": {
"prefix": "management.trace.http",
@MarounMaroun
MarounMaroun / CacheConfiguration.java
Created Mar 23, 2019
Spring 2.x Redis configurations
View CacheConfiguration.java
import java.time.Duration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@MarounMaroun
MarounMaroun / commit-msg.sh
Last active Jun 26, 2018
Add branch name to commit message githook
View commit-msg.sh
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"
View install_mongo.sh
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 Dec 28, 2017
Call by name VS call by value in Scala
View ByNameValue.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 Dec 18, 2017
AWS instance types extractor
View instance_types_extractor.py
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 Nov 25, 2017
Clone all of your public repositories
View get_repose.sh
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 / strict_vs_lazy.scala
Created Nov 22, 2017
Strict VS Lazy evaluation in Scala
View strict_vs_lazy.scala
/**
* Assume we are interested in finding the first two even numbers in a very big file.
* Since we love functional programming, we don't want to use the traditional for loops.
* Instead, we want to apply a series of function to get the desired output.
*/
// for the sake of the example, I assume the input is found in a list, not a file
var l = List(1, 47, 38, 53, 51, 67, 39, 46, 93, 54, 45, 33, 87, 96, 100, 4, 84, 17, 31, 81, 88, 35, 36)
// we don't really need toList here, but since we're assuming the data is coming from a file, I'll use it anyway
@MarounMaroun
MarounMaroun / SingletonExample.scala
Created Nov 21, 2017
Scala singleton example using object
View SingletonExample.scala
object Singleton {
private var i = 0
def create(): Int = {
i += 1
i
}
}
Singleton.create() // 1
You can’t perform that action at this time.