Skip to content

Instantly share code, notes, and snippets.

Avatar

Grégoire MOLVEAU gmolveau

View GitHub Profile
@gmolveau
gmolveau / 1.srp.py
Created Sep 11, 2022 — forked from dmmeteo/1.srp.py
SOLID Principles explained in Python with examples.
View 1.srp.py
"""
Single Responsibility Principle
“…You had one job” — Loki to Skurge in Thor: Ragnarok
A class should have only one job.
If a class has more than one responsibility, it becomes coupled.
A change to one responsibility results to modification of the other responsibility.
"""
class Animal:
def __init__(self, name: str):
@gmolveau
gmolveau / .Xmodmap
Created Sep 8, 2022
linux/ubuntu disable next/previous mouse clicks/buttons
View .Xmodmap
# ~/.Xmodmap
# disable next/previous mouse clicks
pointer = 1 2 3 4 5 6 7 0 0
@gmolveau
gmolveau / mount_lvm_usb.sh
Last active Aug 23, 2022
linux/lvm mount external USB LVM partition
View mount_lvm_usb.sh
sudo vgscan
# note vg name
sudo vgchange -ay <VG-NAME>
sudo lvdisplay
# note `LV Path`
sudo mkdir -p /media/usb/lvm_usb
sudo mount <LV-PATH> /media/usb/lvm_usb
# to automount this partition
sudo nano /etc/fstab
@gmolveau
gmolveau / fix-vgname.sh
Created Aug 23, 2022
linux/lvm fix duplicate vg names with vgrename uuid
View fix-vgname.sh
sudo vgdisplay
# note UUID
sudo vgrename <UUID> <new-vg-name>
# done.
@gmolveau
gmolveau / spotlight_index_reset.sh
Created Aug 23, 2022
macos spotlight index reset
View spotlight_index_reset.sh
sudo mdutil -Ea
sudo mdutil -ai off
sudo mdutil -ai on
@gmolveau
gmolveau / docker_run_cypress_x11.sh
Created Jul 27, 2022
linux/ubuntu docker run cypress with x11 forwarding xhost
View docker_run_cypress_x11.sh
xhost +local:docker
docker run --rm -it -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -e XAUTHORITY=/.Xauthority -v $HOME/.Xauthority:/.Xauthority --entrypoint cypress cypress/included:10.3.0 open --project .
@gmolveau
gmolveau / git-rimraf
Created Jul 7, 2022
git-rimraf : delete branches that don't exist on remote
View git-rimraf
#!/bin/bash
git fetch -p && (git for-each-ref --format='%(if:equals=[gone])%(upstream:track)%(then)%(refname:short)%(end)' refs/heads; git for-each-ref --format "%(refname:short) %(upstream)" refs/heads | awk '{if (!$2) print $1;}') | grep -E -v 'master|main|develop' | xargs echo git branch -D
# explanation
# - `git fetch -p` : fetch branches that no longer exist on remote
# - `git for-each-ref --format='%(if:equals=[gone])%(upstream:track)%(then)%(refname:short)%(end)' refs/heads` : list all branches that no longer exist on remote
# - `git for-each-ref --format "%(refname:short) %(upstream)" refs/heads | awk '{if (!$2) print $1;}'` : list all branches without a remote
# - `grep -E -v 'master|main|develop'` : remove master, main, develop branches from the results
# - `xargs echo git branch -D` : print the commande to delete those branches (remove echo if you want to exec this command directly)
@gmolveau
gmolveau / todo.txt
Created Jun 29, 2022
todo.txt format
View todo.txt
x (A) 2015-05-20 2016-04-30 measure space for +chapelShelving @chapel due:2016-05-30
│ │ │ │ │ │ └─ Special key/value tag
│ │ │ │ │ └─ Context tag
│ │ │ │ └─ Project tag
│ │ │ └─ Optional - Creation date
│ │ └─ Optional - Completion date
│ └─ Optional - Marks priority
└─ Optional - Marks completion
> https://github.com/todotxt/todo.txt#todotxt-format-rules=
View hellfest_2022.md
@gmolveau
gmolveau / python_mock.md
Created Jun 23, 2022
“Don’t Mock What You Don’t Own” in 5 Minutes #python
View python_mock.md