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
type PanicFilter struct {
mq.Handler
logger *log.Logger
}
func (f PanicFilter) Handle(d amqp.Delivery) error {
defer func() {
if panic := recover(); panic != nil {
defer d.Nack(false, false) // might have been ACK/NACK already, but for safety.
_, file, line, ok := runtime.Caller(4)

Keybase proof

I hereby claim:

  • I am bench on github.
  • I am benchenebault (https://keybase.io/benchenebault) on keybase.
  • I have a public key whose fingerprint is 491D A06E 23F7 CE36 6434 615F EA54 A69B 6EF8 462A

To claim this, I am signing this object:

@bench
bench / retrieve_project_version_from_pom.sh
Last active November 20, 2017 10:16
retrieve project version from maven pom.xml
#!/bin/bash
mvn help:evaluate -Dexpression=project.version | grep -Ev 'INFO|WARNING'
@bench
bench / apt-get.md
Last active November 20, 2017 14:32
dpkg & apt-get cheatsheet

dpkg vs apt-get

dpkg is the acronym for debian package. It's the package management system of Debian and its derivatives.

apt-get means Advanced Packaging Tool. It is a front-end for dpkg that automates installation and configuration.

dpkg commands

A Debian package ".deb" always follows the convention [softname]_[version]_[architecture].deb

@bench
bench / generate_rsa.md
Last active January 16, 2018 15:10
generate private and public rsa keys

First option

$ openssl genrsa -out mykey.pem 1024 # build rsa private key
Generating RSA private key, 1024 bit long modulus
............................................................++++++
....++++++

$ openssl rsa -in mykey.pem -pubout > mykey.pub  # build --BEGIN PUBLIC KEY-- format public key
writing RSA key
@bench
bench / function_sample.sh
Created February 7, 2018 20:39
Ecrire une fonction shell
function stdout {
echo "$(date "+%H:%m:%s") $@"
}
@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]}"
@bench
bench / trigger-gitlab-job.sh
Last active February 12, 2018 13:30
gitlab multi project pipeline alternative
#!/bin/bash
# downstream, a tool to trigger gitlab CI pipelines
#
# DESCRIPTION
#
# downstream offers a way to trigger a pipeline on a specific branch of one or multiple projects
# Project are identified by their numerical IDs.
# Project IDs can be found under Settings->General->General project settings
# When a branch is not found, it is created from the master and then the pipeline is triggered
@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 / 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