Skip to content

Instantly share code, notes, and snippets.

@Xowap
Xowap / patch_idea_env.py
Last active April 10, 2017 10:42
Patch IDEA run configurations with environment variables from a file
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import argparse
import re
import os
import subprocess
import re
import json
import asyncio
from textwrap import dedent
from urllib.parse import urljoin
from aiohttp import web
async def index(_):
return web.Response(text="""
@Xowap
Xowap / anonymize_email.py
Created July 3, 2017 08:34
A script to anonymize emails in a SQL dump
#!/usr/bin/env python3
# coding: utf-8
import argparse
import re
from uuid import uuid4
from hashlib import sha256
SALT = str(uuid4()).encode()
#!/bin/bash
SERVBIN=${SERVBIN:-/usr/sbin/service}
success=0
function echo_rep {
echo -n $(tput cuu1)
echo -n $(tput ed)
echo "$1"
}
@Xowap
Xowap / default.py
Last active December 6, 2017 11:03
An attempt to validate data as you read it (something in the mood of PEP 463)
from typing import TypeVar, Callable, Any, Optional, Tuple, Type
DATA_ERROR = (
KeyError,
TypeError,
ValueError,
AttributeError,
IndexError,
AssertionError,
)
@Xowap
Xowap / gdpr.yml
Last active December 27, 2018 11:28
---
# List here all data controllers
controllers:
- name: Control Corporation
address: 42 control road, 75000 Paris, France
organisational_part: Control Part
contact_person: Jean-Claude Control
# That's all recipients for this data, wether internal database or an
@Xowap
Xowap / serialized_replace.py
Last active June 6, 2018 16:08
Search & Replace in PHP serialized values
#!/usr/bin/env python3
from argparse import ArgumentParser
from sys import stdin, stdout
import re
SER_STR = re.compile(r"s:(\d+):(\\*\")(.*?)(\\*\");")
def parse_args():
@Xowap
Xowap / requests_html_hotfix.py
Last active July 9, 2018 13:58
Fix pyppeteer download location
"""
This is a monkey patch of the requests-html module so it can download chrome
and store its data in a custom location and not in the home directory (which
is not writable on servers and also we do not want chrome stored there).
"""
from os.path import (
join,
)
from pathlib import (
@Xowap
Xowap / house_avocode.svg
Last active December 7, 2018 07:33
Avocode SVG optimization
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Xowap
Xowap / jupiter_lci.py
Created August 2, 2019 14:18
Jupiter LCI
from argparse import ArgumentParser, Namespace
from base64 import b64encode
from json import dumps
from pprint import pprint
from typing import Optional, Sequence, Text
from urllib.parse import ParseResult, urljoin, urlparse
from requests_html import HTMLSession