Skip to content

Instantly share code, notes, and snippets.

View raphaelfruneaux's full-sized avatar

Raphael Fruneaux raphaelfruneaux

View GitHub Profile
@raphaelfruneaux
raphaelfruneaux / vcr_replacer.py
Last active January 19, 2022 19:34
A Pytest-VCR sensitive data replacer setup
import json
import pytest
REPLACEMENT_VALUE = "fake"
SENSITIVE_FIELDS = (
"client-id",
"client-secret",
"access_token",
"Authorization",
import pytest
from django.db.models.signals import (
m2m_changed,
post_delete,
post_save,
pre_delete,
pre_save,
)
@raphaelfruneaux
raphaelfruneaux / .gitconfig
Created November 24, 2020 15:20
Git aliases
[alias]
# View abbreviated SHA, description, and history graph of the latest 20 commits
l = log --pretty=oneline -n 20 --graph --abbrev-commit
# View the current working tree status using the short format
s = status
# Show the diff between the latest commit and the current state
d = !"git diff-index --quiet HEAD -- || clear; git --no-pager diff --patch-with-stat"
@raphaelfruneaux
raphaelfruneaux / split_in_chunks.py
Last active January 5, 2022 21:26
This function split an iterable into a new iterable with pieces of a certain size
from itertools import islice
def split_in_chunks(iterable, size=10):
iterable = iter(iterable)
while chunk := tuple(islice(iterable, size)):
yield chunk
@raphaelfruneaux
raphaelfruneaux / pre-commit
Created April 6, 2020 01:09 — forked from acdha/pre-commit
Git pre-commit hook which runs various code linters. Install this to .git/hooks/pre-commit inside your favorite repos
#!/usr/bin/env PYTHONIOENCODING=utf-8 python
# encoding: utf-8
"""Git pre-commit hook which lints Python, JavaScript, SASS and CSS"""
from __future__ import absolute_import, print_function, unicode_literals
import os
import subprocess
import sys
class FooBar:
# class attribute
foo = "foo"
def __init__(self):
# instance attribute
self.bar = "bar"
def greeting(f):
def wrapper(*args, **kwargs):
print("Hi there! Welcome!")
f(*args, **kwargs)
print("Byee!")
return wrapper
@greeting
def foo():
# how to create a generator
def numbers():
for n in range(100):
yield n
# how to create a generator expression
numbers = (n for n in range(100))
def invert_int(n):
if not n:
return
print(int(str(n)[::-1]))
@raphaelfruneaux
raphaelfruneaux / README.md
Created January 5, 2019 00:44 — forked from bvis/README.md
Docker Env Vars expanded with secrets content

Variables by Secrets

Sample script that allows you to define as environment variables the name of the docker secret that contains the secret value. It will be in charge of analyze all the environment variables searching for the placeholder to substitute the variable value by the secret.

Usage

You can define the next environment variables: