Skip to content

Instantly share code, notes, and snippets.

// Idea from this tweet https://twitter.com/dei_biz/status/1572532695183523842?s=20&t=4VCKMl_BJSfWBETNhtyEbA
// All credit to ttps://github.com/dei-biz
[...document.querySelectorAll("*")].map(e=> http://e.style.color = "RGBA(0,0,0,0)")
# Alias to show git log with nice format.
# then you can:
# $ git lg | lg1
# $ git lg2
# To show the log
# based on: https://stackoverflow.com/questions/1057564/pretty-git-branch-graphs
[alias]
lg1 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
@jomoespe
jomoespe / .bash_profile
Last active December 2, 2020 07:49
Put Git branch in the prompt
# Put the Git branch in the prompt
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
export PS1='\[\033[1;34m\]\w\[\033[1;95m\]$(parse_git_branch)\[\033[0m\]$ '
@jomoespe
jomoespe / Makefile
Created January 7, 2020 15:06
Ckeck executable dependencies in a Makefile
# Check if all executables needed are in the PATH before execite any rule/task.
EXECUTABLES = rm mkdir cp mvn java go # List of executables
CHECK_EXECUTABLES := $(foreach exec,$(EXECUTABLES),\
$(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH. Check README.md for build requirements")))
# This must be at the begining of the file, so ASAP make parses the file will fail if some of
# dependencies does not exist
@jomoespe
jomoespe / go.mod
Created December 12, 2019 08:42
Format and colorize Go console output
module github.com/jomoespe/align-text
go 1.13
require github.com/logrusorgru/aurora v0.0.0-20191116043053-66b7ad493a23
@jomoespe
jomoespe / Dockerfile
Created November 26, 2019 22:55
Non-privileged Docker image from scratch
# Non-privileged containers based on the scratch image
# https://medium.com/@lizrice/non-privileged-containers-based-on-the-scratch-image-a80105d6d341
FROM ubuntu AS base
RUN useradd -u 10001 user
RUN mkdir /home/user
FROM scratch
COPY --from=base /etc/passwd /etc/passwd
COPY --from=base /home/user /home/user
@jomoespe
jomoespe / Fail-fast shellscript library.md
Last active August 16, 2019 19:10
Fail-fast bash library example

Fail-fast the execution of a bash library script

This is an example of bash library usage. The library fail-fast if you try to use directly from CLI.

The library contains the shebang and execution permissions only for the examples. Not needed in production code (the shebaang and the permissions).

Examples

@jomoespe
jomoespe / mergeParquet.scala
Created February 14, 2019 07:28
Snippet of Spark job to merge parquet files, also removing duplicates
val partitions = 5; // this value depends on data and volumes. Will be different in every case.
val df = sqlContext.read.json(“URI://path/to/parquet/files/")
df.createOrReplaceTempView("df")
val df_output = spark
.sql("SELECT DISTINCT * FROM df") // this removes duplicates. If it's not needed, simply remove this line
.coalesce(partitions)
df_output.write.parquet("URI://path/to/destination")
@jomoespe
jomoespe / html-flex-basic-template.html
Created September 4, 2017 21:04
A simple example of flex layout
<html>
<style type="text/css">
* {
margin: 0;
padding: 0;
font-size: 10px;
}
div {
display: flex;
flex-direction: row;
@jomoespe
jomoespe / html-grid-basic-template.html
Last active September 19, 2018 10:39
A basic HTML template structured with grid layout
<html>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
html {
font-size: 62.5%;
box-sizing: border-box;