Skip to content

Instantly share code, notes, and snippets.

View Julien00859's full-sized avatar
😴
425 - Too Early

Julien Castiaux (juc) Julien00859

😴
425 - Too Early
View GitHub Profile
@Julien00859
Julien00859 / password.py
Created February 21, 2026 20:28
Generate a 256 bits strong random password.
#!/usr/bin/env python3
import argparse
import math
import string
import sys
from random import SystemRandom
lowers = set(string.ascii_lowercase)
uppers = set(string.ascii_uppercase)
digits = set(string.digits)
# Part of Odoo. See LICENSE file for full copyright and licensing details.
"""
Utilities to work with partial zip files.
The zipfile library found in the python standard library only work with
full zipfile, i.e. the entire zipfile must be created/loaded in memory.
There are situations where we don't want to load the entire thing in
memory, e.g. to craft a zipfile out of many large file and to send it
over the network.
#!/usr/bin/env python3
import docutils.core
import fileinput
import inspect
import sys
from docutils import nodes
from docutils.parsers.rst import roles
from docutils.parsers.rst.directives.admonitions import Note
class TicTacToe:
def __init__(self, first_player="x"):
self.board = [[" " for _ in range(3)] for _ in range(3)]
self.player = first_player
self._turns = []
@property
def other_player(self):
return {"x": "y", "y": "x"}[self.player]
@Julien00859
Julien00859 / pyproject.toml
Last active August 4, 2023 23:27
pyproject sample
# src-layout
# replace the many <module>!
[build-system]
requires = ["setuptools>=61.0", "setuptools_scm[toml]>=6.2"]
build-backend = "setuptools.build_meta"
[project]
name = "<module>"
version = "0.0.1"
@Julien00859
Julien00859 / commitstrip.md
Last active April 13, 2026 12:01
Commitstrip date/title/jpg-link database

Description

Le CTO est assit à son bureau, son chat sur les épaules, il fait passer un entretient à un candidat. L'entretient semble bien se passer jusqu'à ce que le CTO apprenne que le candidat utilise internet explorer 7 pour développer.

Transcript

CTO: Et le code HTTP 418 tu connais ?
Candidat: Oui "I'm a teapot RFC 2324"

@Julien00859
Julien00859 / deemaze_large.txt
Created January 15, 2023 02:33
Deepmaze visualizer
#a# #b# #c#
################################# ### ###
################################### ### ##################
### ### ### ####################
### \\\\################# ### ### ### ###
### ////################# ### ### ### ###
### +----------###-+ ### ### +-###----------+ ###
l############## c | ### ### ##### a ####### #####d
###############l | ### ### ######l d###### #######
| | ### ### ### | | ###
# Using those electronic building blocs:
#
# NOT GATE NAND GATE NOR GATE
#
# GNR GNR GNR
# a------< a------< a------< |
# POW-ww-+-c b------< b------(-<
# POW-ww-+--c POW-ww-+-+--c
#
# We define "and" and "or":
@Julien00859
Julien00859 / odoo_controller.py
Last active January 8, 2021 10:55
Using wsgi, keep the worker alive after the request was fully sent
# Courtesy of JKE
from odoo import http
from functools import partial
from contextlib import closing
import datetime
import time
class JucController(http.Controller):
@Julien00859
Julien00859 / passlib.py
Last active August 31, 2020 16:15
Password hardening mini lib
import secrets
import hashlib
def harden_pwd(pwd: str, version=1) -> bytes:
# scrypt n factor should be at least 2<<15 for interfactive usage,
# oddly enough, a n value higher than 2<<13 doesn't work on my machine
# https://blog.filippo.io/the-scrypt-parameters/
if version == 1:
salt = secrets.token_urlsafe(16).encode() # so there is no $ symbol
hardened = hashlib.scrypt(pwd.encode(), salt=salt, n=2<<13, r=8, p=1)