Skip to content

Instantly share code, notes, and snippets.

@nilleb
nilleb / index.js
Created February 4, 2025 12:35
compare `qs.stringify` and `axios post with a dict` (using content-type `application/x-www-form-urlencoded`)
const axios = require('axios')
const qs = require('qs')
const url = 'https://httpbin.org/post'
const clientId = '9495d6bb-41c2-4c58-848f-92e52cf3d640'
const clientSecret = '9495d6bb-41c2-4c58-848f-92e52cf3d640'
async function stringify(resource) {
let params = {
grant_type: 'client_credentials',
@nilleb
nilleb / README.md
Last active November 11, 2024 13:45
gdrive-openapi.yaml

Somebody has produced a openapi.yaml for Google Drive - Thank you!

And I had a spare application in my Google Cloud Console, so I told myself that I'd like to try to work with Google files directly from ChatGPT.

So I edited a but the file above, to match OpenAI ChatGPT's actions syntax, and here's the outcome.

uv pip compile dev-requirements.in requirements.in > dev-requirements.txt
uv pip compile requirements.in > requirements.txt
uv pip sync dev-requirements.txt requirements.txt
@nilleb
nilleb / impots.py
Last active January 3, 2024 13:39
Impôts sur le revenu et impôt sur les sociétés, comparaison
baremes = [(0, 10777, 0), (10778, 27478, 11), (27479, 78570, 30), (78571, 168994, 41)]
max_bareme, max_pct = 168995, 45
def impot_revenu(val, nombre_parts=1):
val = val - val * 0.1
val = val / nombre_parts
impot = 0
for min_bareme, max_bareme, pct in baremes:
montant_imposable = max(
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
MIT License
Copyright (c) 2016 Matt Menzenski
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@nilleb
nilleb / en.json
Last active August 10, 2023 07:23
cli to help the wordle player solve today's puzzle
["which", "there", "their", "about", "would", "these", "other", "words", "could", "write", "first", "water", "after", "where", "right", "think", "three", "years", "place", "sound", "great", "again", "still", "every", "small", "found", "those", "never", "under", "might", "while", "house", "world", "below", "asked", "going", "large", "until", "along", "shall", "being", "often", "earth", "began", "since", "study", "night", "light", "above", "paper", "parts", "young", "story", "point", "times", "heard", "whole", "white", "given", "means", "music", "miles", "thing", "today", "later", "using", "money", "lines", "order", "group", "among", "learn", "known", "space", "table", "early", "trees", "short", "hands", "state", "black", "shown", "stood", "front", "voice", "kinds", "makes", "comes", "close", "power", "lived", "vowel", "taken", "built", "heart", "ready", "quite", "class", "bring", "round", "horse", "shows", "piece", "green", "stand", "birds", "start", "river", "tried", "least", "field", "whose", "girls", "leave
@nilleb
nilleb / proxy.py
Created July 11, 2022 19:12
CORS proxy
# -*- coding: utf-8 -*-
# forwards the calls to http://localhost:8000/https://google.com to https://google.com - copying the headers, query strings, etc
from fastapi import FastAPI, Request, Response
from fastapi.middleware.cors import CORSMiddleware
import requests
app = FastAPI()
@nilleb
nilleb / README.md
Last active January 6, 2018 13:33
Hack: use google-cloud-spanner in a google-app-engine app
@nilleb
nilleb / relengprinciples.md
Last active February 14, 2025 10:46
Release engineering principles

This documents details my release engineering principles. They have been forged through experience, no need to say. :-)

The context is: you want to build your software, and eventually distribute it. You are not alone, and even if, you're not immortal. If you want your creation to live after you,

You need

  • An objective, repeatable, exhaustive process.
    • No hidden knowledge.
    • No environmental prerequisites.
  • In three years, you should be able to get the same binaries you get today.
for /f %%i in ('git rev-parse --abbrev-ref HEAD| sed "sI.*/IIg"') do set branch=%%i
git show-branch 2> nul | grep '\*' | grep -v "%branch%" | head -n1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//'
# How it works:
# 1| Display a textual history of all commits.
# 2| Ancestors of the current commit are indicated
# by a star. Filter out everything else.
# 3| Ignore all the commits in the current branch.
# 4| The first result will be the nearest ancestor branch.