Skip to content

Instantly share code, notes, and snippets.

View bench's full-sized avatar
🏠
Working from home

Benjamin Chenebault bench

🏠
Working from home
View GitHub Profile
@bench
bench / arch_install
Last active October 6, 2020 12:13
arch install with encrypted disk, ext4 partition, no LVM, one swap file, i3 desktop.
# Create a bootable arch key and boot on it
# load your keymap
loadkeys fr
# connect to internet
iwclt
> station wlan0 scan
> station wlan0 connect SSID
@bench
bench / gitlab-runner-creation.sh
Created April 5, 2019 09:28
Create a docker runner with socket binding
sudo gitlab-runner register --tag-list "docker" --docker-volumes "/var/run/docker.sock:/var/run/docker.sock" \
--url "https://gitlab.mycompany.com/" --registration-token "Y1riedimjQuJ-rBK-SHe" --executor "docker" \
--description "ci1-docker-temp" --docker-image "docker:stable" --docker-privileged
@bench
bench / cleanup.js
Created August 20, 2018 20:31
remove all documents from a mongoDB database
// This method preserves mongo indexes
db.getCollectionNames().forEach(function(collname) {
db[collname].remove({})
})
@bench
bench / .gitconfig
Created May 23, 2018 09:19
My gitconfig file
[user]
name = Benjamin Chenebault
email = benjamin.chenebault@gmail.com
[push]
default = simple
[alias]
cp = cherry-pick
st = status -s
cl = clone
ci = commit
@bench
bench / terraform_aws.md
Created May 4, 2018 13:56
Terraform et AWS

Terraform sur AWS

un VPC permet de créer un réseau virtuel et de la configurer. C'est une isolation logique. On distingue subnet public avec IP accessible et subnet privée qui a besoin d'une NAT gateway. Terraform est un outil créé par Hashicorp qui fait de l'infra as code. On fait du déclaratif, et terraform se charge de monter/démonter les machines pour nous. Il est compatible multicloud et pas seulement AMAZON.

A l'initialisation, on commence par un

@bench
bench / cloud_acronyms.md
Created May 4, 2018 13:56
Cloud computing acronyms
  • IAAS (infrastructure as a service) : Permet de monter des machines, c'est de la VM, de l'automatisation. On déplacait l'infrastructure.
  • CAAS (container as a service) : Virtualisation non plus par VM mais par containers tel que Docker. Les fournisseurs peuvent fournir des plateformes d'orchestration dont Google Kubernetes ou Docker Swarm. PAAS (platform as a service) : google app engine, amazon S3, etc, ce sont des sevices managés
  • BAAS (backend as a service) : Ce n'est pas un service de cloud mais un concept d'architecture qui fournit l'authentification, la scalabilité automatique, et des services tels que les push notifications pour le développement d'app mobile.
  • FAAS (functions as a service) : La plate-forme qui instancie à la volée une fonction lors d'un appel d'API. On ne paie plus en nombre de machine ou autre mais au nombre d'appels d'API
@bench
bench / getall.js
Created March 30, 2018 19:26
Sample of GET /ALL - TP Redis - EPSI
const getAsync = util.promisify(client.get).bind(client);
const keysAsync = util.promisify(client.keys).bind(client);
app.get('/notes', async function (req, res, next) {
var promises = [];
await keysAsync('*').then(function (keys) {
console.log("got "+ keys)
keys.forEach(function (key) {
console.log(key);
@bench
bench / condition_syntax_bash.sh
Created February 7, 2018 21:09
conditions syntax in bash
## check the return of a command
if command; then
[...]
fi
## check by string comparison / numerical / file existence / or more
if [[ CHECK ]]; then
[...]
fi
@bench
bench / while_for_syntax_bash.sh
Created February 7, 2018 20:50
while and for loop syntax in bash
# While loop
while [ $i -lt 10 ];
do
[...]
done
# C style for loop
for (( c=1; c<=$MAX_VAL; c++ ))
do
[...]
@bench
bench / manipulate_array_bash.sh
Last active February 7, 2018 20:43
declare and use an array bash
declare -a MYARRAY
# Static index
MYARRAY[0]="first value"
# Dynamic index
MYARRAY[${i}]="another value"
# Access an element of an array
echo "Hello my value is ${MYARRAY[$i]}"