Skip to content

Instantly share code, notes, and snippets.

View tarrsalah's full-sized avatar
🐧

Salah Eddine Taouririt tarrsalah

🐧
View GitHub Profile
@tarrsalah
tarrsalah / atomic-git-commits.md
Last active March 12, 2023 16:24
Every commit should be a perfect, atomic unit of change

Original post published on gemini://drewdevault.com/2021/01/02/2021-01-02-Every-commit-should-be-perfect.gmi


Every commit should be a perfect, atomic unit of change

Good commit discipline with git pays dividends in many respects, most of which are difficult to achieve with other version control systems. Each commit to your repository’s main branch should be exactly the correct size, be it large or small, such that it introduces one atomic unit of change. It should fix one bug, introduce one feature, refactor one system, and do so completely, rather than spreading the change out across several commits.

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<title>Document</title>
</head>
<body>
<table>
<tr>
<td id="first"></td>
# PS1
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
LightRed="\[$(tput bold ; tput setaf 1)\]"
Yellow="\[$(tput bold ; tput setaf 3)\]"
LightCyan="\[$(tput bold ; tput setaf 6)\]"
NC="\[$(tput sgr0)\]" # No Color
@tarrsalah
tarrsalah / docker-compose.yaml
Created May 30, 2018 09:48
docker-compose example
version: "3.6"
services:
web:
build:
context: .
volumes:
- "~/src/github.com/tarrsalah/dolibarr:/var/www/html"
ports:
- "3000:80"
@tarrsalah
tarrsalah / strangeObject.js
Created January 13, 2018 14:41
Strange syntax to create an object in javascript
const stringArray = ["STRING_ARRAY"];
const strangeObject = {
[stringArray]() {
console.log(stringArray);
}
};
import os
import shutil
src_dir = os.curdir
dst_dir = os.path.join(os.curdir, "dest")
filenames = os.path.join(os.curdir, "filenames.txt")
def get_filenames():
lines = []
with open(filenames) as file:
@tarrsalah
tarrsalah / add.m
Last active August 2, 2017 23:34
Execute a function with arguments from the commande-line
#!/usr/bin/octave --silent
a = str2num(argv(){1});
b = str2num(argv(){2});
printf("%d\n", a + b);
#!/bin/bash
GIT_DIR="PATH_TO_GIT_REPO"
GIT_WORK_TREE="PATH_TO_GOT_WORKTREE"
mkdir -p $GIT_WORK_TREE
git --work-tree=$GIT_WORK_TREE --git-dir=$GIT_DIR checkout -f master
(cd $GIT_WORK_TREE && make)
@tarrsalah
tarrsalah / inarp.go
Last active May 9, 2016 05:57
invalidate my ARP cache every 500ms
package main
import (
"os/exec"
"time"
)
func inarp() {
cmd := exec.Command("/bin/sh", "-c", "sudo ip -s -s neigh flush all")
stdout, err := cmd.Output()
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
LightRed="\[$(tput bold ; tput setaf 1)\]"
Yellow="\[$(tput bold ; tput setaf 3)\]"
LightCyan="\[$(tput bold ; tput setaf 6)\]"
NC="\[$(tput sgr0)\]" # No Color
export PS1="\u:${LightRed}$\w${Yellow}\$(parse_git_branch)\n ${LightCyan}λ ${NC}"