Skip to content

Instantly share code, notes, and snippets.

View clemlatz's full-sized avatar

Clément Latzarus clemlatz

View GitHub Profile
@clemlatz
clemlatz / self-signed-ssl-certificate.md
Last active January 3, 2025 23:24
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
@clemlatz
clemlatz / nginx-config.conf
Last active December 23, 2022 10:43
Set up ssl proxy with nginx and letsencrypt (https://secure.example.com => http://example.com)
# SSL server config
server {
listen 443 ssl;
server_name secure.example.com;
ssl_certificate /etc/letsencrypt/live/secure.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/secure.example.com/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
@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,
Moved to: https://github.com/iwazaru/cheatsheets/blob/master/git.md
@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 / setup.sh
Last active August 9, 2019 00:00
Set up nginx + letsencrypt ssl on Mac OSX El Capitan
# Install nginx with brew
brew install nginx
# Install PIP
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
# Get letsencrypt
git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt
@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