Skip to content

Instantly share code, notes, and snippets.

@ddebin
ddebin / check-coverage.sh
Last active February 9, 2023 11:30
Check Clover[.xml] coverage
#!/usr/bin/env bash
# coverage-check.sh - Check coverage.svg from a clover.xml, xmllint needed.
#
# Copyright (C) 2022 Damien Debin (<https://github.com/ddebin>)
# License: The MIT License <http://opensource.org/licenses/MIT>
#
# SPDX-License-Identifier: MIT
set -e # fail if any commands fails
@ddebin
ddebin / bookmarklet.js
Last active November 2, 2020 14:23
Remplissage automatique (bookmarklet) pour l'attestation de déplacement https://media.interieur.gouv.fr/deplacement-covid-19/
javascript: (() => {
const now = new Date(Date.now() + 5 * 60 * 1000 /* délai de 5min en ms */);
/* modifiez les champs suivants avec vos informations */
const fields = {
"field-firstname": "Camille",
"field-lastname": "Dupont",
"field-birthday": "01/01/1970",
"field-placeofbirth": "Paris",
"field-address": "999 avenue de France",
"field-city": "Paris",
@ddebin
ddebin / filter_cr.sh
Created July 20, 2020 14:23
How-to filter out a screenlog.0 to remove useless CR (useful if you want to convert ANSI text to PNG)
#!/bin/bash
cat screenlog.0 | perl -ne 's/[^\r\n]*\r(?!\n)//g; print;' > screenlog.0.filtered
@ddebin
ddebin / mysql_update_database_charset.sh
Last active May 22, 2019 16:04
Update MySQL Database charset/collate (and all tables)
#!/bin/bash
# cf. https://lxadm.com/MySQL:_changing_database_character_set_and_collate
# cf. https://medium.com/@alexBerg/my-war-with-mysql-or-how-did-i-switch-to-full-utf8mb4-73b257083ac8
# Assume MySQL authentication done via .my.cnf
DATABASE="db_name"
#CHARACTER_SET=utf8
#COLLATE=utf8_unicode_ci
@ddebin
ddebin / ecr_tag.sh
Created January 31, 2019 15:42
Shell script to add/remove tags to an AWS ECR image.
#!/bin/bash
set -e
function help() {
echo "Not enough arguments supplied..."
echo
echo "Usage: $0 aws_repo_name {add|delete} tag [to_image_id_query]"
echo
echo "Example: $0 ecr_repo add v1.0.0 imageTag=production"
echo "Example: $0 ecr_repo remove v1.0.0.beta"
@ddebin
ddebin / update_sg_with_cf_netblocks.sh
Last active September 23, 2022 07:42
Update AWS Security Group sg-xxxxxxxx with rules to let inbound TCP traffic on ports 80|443 coming from Cloudflare netblocks
#!/bin/bash
# update_sg_with_cf_netblocks.sh sg-xxxxxxxx 80
if [ "$#" -ne 2 ] || ! [[ "$2" =~ ^[0-9]+$ ]]; then
echo "Update AWS Security Group sg-xxxxxxxx with rules to let inbound TCP traffic on ports 80|443 coming from Cloudflare IPv4/IPv6 netblocks."
echo "Usage: $0 sg-xxxxxxxx port_number" >&2
exit 1
fi
DONE=false
@ddebin
ddebin / keybase.md
Last active August 29, 2015 14:07
Keybase.io proof

Keybase proof

I hereby claim:

  • I am ddebin on github.
  • I am ddebin (https://keybase.io/ddebin) on keybase.
  • I have a public key whose fingerprint is 85AC 5448 8C1B 6C95 806B AFF2 993D 6CCC 56AC 2BDD

To claim this, I am signing this object:

@ddebin
ddebin / rsync.xml
Created December 6, 2013 13:58
ESXi service description for rsync in daemon mode.
<ConfigRoot>
<service>
<id>rsync</id>
<rule id="0000">
<direction>outbound</direction>
<protocol>tcp</protocol>
<porttype>dst</porttype>
<port>873</port>
</rule>
<rule id="0001">
@ddebin
ddebin / converter.php
Last active December 27, 2015 09:28
Ce script convertit un backup/export DotClear ("blog-backup.txt" flatExport) en posts markdown pour Octopress/Jekyll (ou autres) et en un fichier de commentaires WXR (WordPress eXtended RSS) pour import XML sur Disqus.
<?php
// --
// - Ce script convertit un backup/export DotClear en posts markdown pour Octopress/Jekyll (ou autres)
// et en un fichier de commentaires WXR (WordPress eXtended RSS) pour import XML sur Disqus.
// - Il faut installer le plugin "flatExport" dans DotClear pour récupérer le "blog-backup.txt"
// cf. http://plugins.dotaddict.org/dc1/details/flatExport
// - Vous avez besoin de Pandoc d'installé sur la machine pour la conversion vers Markdown
// cf. http://johnmacfarlane.net/pandoc/
// --
<?php
// ISO 639-1 language codes coming from http://www.loc.gov/standards/iso639-2/ISO-639-2_utf-8.txt
$iso_array_lang = array(
'ab'=>'Abkhazian',
'aa'=>'Afar',
'af'=>'Afrikaans',
'ak'=>'Akan',
'sq'=>'Albanian',
'am'=>'Amharic',
'ar'=>'Arabic',