Skip to content

Instantly share code, notes, and snippets.

View clemlatz's full-sized avatar

Clément Latzarus clemlatz

View GitHub Profile
@clemlatz
clemlatz / Dockerfile
Last active January 17, 2020 11:57
Configure Matomo to use environment variables using Docker
# Extend the official Matomo Docker image
FROM matomo:3.13.0
# Install unzip
RUN apt update && apt install -y unzip
# Download, unzip and install the EnvironmentVariables plugin
RUN curl -o EnvironmentVariables.zip \
https://plugins.matomo.org/api/2.0/plugins/EnvironmentVariables/download/latest \
&& unzip EnvironmentVariables.zip \
@clemlatz
clemlatz / remove-paywall.js
Created January 10, 2020 09:08
Remove Le Parisien paywall
document.querySelector('.piano-paywall').remove();
[].forEach.call(document.querySelectorAll('.content'), div => div.style.filter = 'none');
@clemlatz
clemlatz / guest-sort.js
Last active September 28, 2018 07:48
Sort guests
(function() {
const getLastName = guest => {
const title = guest.querySelector('.title-nom-prenom');
const names = title.textContent.split(' ');
return names[names.length - 1];
}
const isotope = document.querySelector('#isotope-list-invites');
const guests = Array.prototype.slice.call(isotope.querySelectorAll('a'));
guests.sort((a, b) => {
const aLastName = getLastName(a);
@clemlatz
clemlatz / keybindings.json
Last active May 15, 2018 10:18
VSCode config
[
{
"key": "cmd+0",
"command": "workbench.action.openLastEditorInGroup"
},
{
"key": "cmd+1",
"command": "workbench.action.openEditorAtIndex1"
},
{
@clemlatz
clemlatz / redux-basics.js
Created February 6, 2018 12:31
Redux basics
const redux = require('redux');
const createStore = redux.createStore;
const initialState = {
counter: 0,
};
// Reducer
@clemlatz
clemlatz / convert-eps-to-jpg.sh
Created January 15, 2018 10:54
Convert EPS files to JPEG
# Remove single quote and space in file names
for f in *\'*; do mv "$f" "${f//\'/_}"; done
for f in *\ *; do mv "$f" "${f//\ /_}"; done
# Convert to PDF
echo *.eps | xargs -n1 pstopdf
# Move files to pdf folder
cd ../pdf/
mv $(echo ../eps/*.pdf) .
@clemlatz
clemlatz / pre-commit-eslint
Last active January 11, 2018 11:20 — forked from linhmtran168/pre-commit-eslint
Pre-commit hook to check for Javascript using ESLint
#!/bin/bash
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".jsx\{0,1\}$")
if [ "$STAGED_FILES" = "" ]; then
exit 0
fi
PASS=true
@clemlatz
clemlatz / README.md
Last active December 6, 2017 13:59
puma daemon management

Puma daemon management

Install

  1. Save puma.rb file locally (eg. to ~/bin/puma.rb)
  2. Create alias alias p='~/bin/puma.rb in bash.rc

Usage

Start server

@clemlatz
clemlatz / smooth-scroll.js
Created September 6, 2017 08:56
Simple smooth-scroll animation in pure/vanilla javascript
/**
* Smooth scroll animation
* @param {int} endX: destination x coordinate
* @param {int) endY: destination y coordinate
* @param {int} duration: animation duration in ms
*/
window.smoothScrollTo = function(endX, endY, duration) {
var startX = window.scrollX || window.pageXOffset,
startY = window.scrollY || window.pageYOffset,
distanceX = endX - startX,
@clemlatz
clemlatz / self-signed-ssl-certificate.md
Last active April 22, 2024 12:30
Setup a self-signed SSL certificate with Nginx (server and browser)

1. Configure server: Nginx

Create the certificate:

$ sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt

Create a strong Diffie-Hellman group:

$ sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048