Skip to content

Instantly share code, notes, and snippets.

@Kmaschta
Kmaschta / generate-self-signed-certificate-with-custom-CA.md
Created January 9, 2019 14:43
How to generate a self-signed that is valid for your browser (by creating your custom certificate authority)

If you're using self-signed certificate for your web server on development, you might know the browser warning saying that your certificate isn't valid. If like me you had manually added an exception for this certificate error each time it showed up, this gist is for you.

Properly Configure OpenSSL with your DNS aliases

You'll have to create a self-signed certificate with a custom SubjectAltName.

  1. Find your openssl config. find /usr/lib -name openssl.cnf
@Kmaschta
Kmaschta / pre-commit
Last active November 16, 2022 19:35
Pre-commit hook (warn if you have it.only, describe.only, fit or fdescribe)
#!/bin/bash
SRC=$(git rev-parse --show-toplevel)
EXCLUDE="--exclude-dir 'node_modules' --exclude-dir '.git'"
#==========================================================
# Check if I forgot to remove 'only' keyword from tests.
# To make sure that before commit run all tests
only_command="grep -c -h -r $EXCLUDE -E \"(describe|it)\.only\" $SRC | awk -F ':' '{x +=\$0}; END {print x}'"
fonly_command="grep -c -h -r $EXCLUDE -E \"f(it|describe)\(\" $SRC | awk -F ':' '{x +=\$0}; END {print x}'"
only=`eval $only_command`
@Kmaschta
Kmaschta / keybase.md
Created January 15, 2021 11:22
Keybase Proof

Keybase proof

I hereby claim:

  • I am kmaschta on github.
  • I am kmaschta (https://keybase.io/kmaschta) on keybase.
  • I have a public key ASCZaN5SJpgXVcd7XuqosiSCH_kN_xMilDHnwFZ4isGu6wo

To claim this, I am signing this object:

@Kmaschta
Kmaschta / DRF-dynamic-fields.py
Last active September 5, 2020 10:31
Django Rest Framework - Dynamic Fields
# How to display only interesting fields for a Django Rest Framework API
# /?fields=field1,field2,field3
from rest_framework import serializers, pagination
class DynamicFieldsModelSerializer(serializers.ModelSerializer):
"""
A ModelSerializer that takes an additional `fields` argument that
controls which fields should be displayed.
@Kmaschta
Kmaschta / Makefile
Created December 12, 2017 16:49
Artifact deployment example
.PHONY: build
TAG ?=
SERVER ?= staging-server
install:
npm install
start:
node --require reify server.js
@Kmaschta
Kmaschta / Parse-International-Days.js
Created April 29, 2019 11:44
Parse International Days
// https://www.journee-mondiale.com/les-journees-mondiales.htm
(() => {
const links = {};
const articles = document.querySelectorAll('article');
articles.forEach((article, monthIndex) => {
const items = article.querySelectorAll('li');
items.forEach((li) => {
@Kmaschta
Kmaschta / algo-dobble.py
Last active April 12, 2019 19:26
Algorithme Dobble
#!/usr/bin/python
# coding: utf-8
import sys
def plan_projectif(modulo):
"""Génération d'un plan projectif réel
Il est composé d'un plan affine (une matrice) et
des points à l'infini du plan réel.
### Keybase proof
I hereby claim:
* I am kmaschta on github.
* I am kmaschta (https://keybase.io/kmaschta) on keybase.
* I have a public key ASAvkWIvIk1a3VcepH9b0Rl9_wd2ECc7UaHwaUDbLtBuIwo
To claim this, I am signing this object:
@Kmaschta
Kmaschta / index.js
Created March 6, 2018 07:11
Apollo Memory Debug
require('isomorphic-fetch');
const express = require('express');
const { makeExecutableSchema } = require('graphql-tools');
const graphqlHTTP = require('express-graphql');
const books = [
{ title: "Harry Potter and the Sorcerer's stone", author: "J.K. Rowling" },
{ title: "Jurassic Park", author: "Michael Crichton" },
];
@Kmaschta
Kmaschta / index.js
Created February 12, 2018 12:48
Express-Winston Benchmark
const express = require('express');
const winston = require('winston');
const expressWinston = require('./express-winston');
const app = express();
const consoleFormatter = ({ level, meta: { req, res, responseTime, stack } }) => {
let msg = `${winston.config.colorize(level, level)} HTTP ${req.method} ${req.url}`;
if (res) {