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
#!/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 January 25, 2025 22:15
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)
@Julien00859
Julien00859 / .gitignore
Last active February 16, 2021 22:11
Parse memory and time value as int
__pycache__/
build/
dist/
*.egg-info/
*.pyc/
from collections import deque
from itertools import cycle, chain, zip_longest
from pprint import pprint
from random import random, randint, sample, shuffle
class Sudoku:
def __init__(self, grid):
self.grid = grid