Skip to content

Instantly share code, notes, and snippets.

@pcorpet
pcorpet / get_pylint_enabled_rules.py
Created September 19, 2024 07:47
Script to help migrate Pylint config to Ruff.
#!/usr/bin/python3
# Script to help migrate Pylint config to Ruff.
#
# It lists enabled Pylint rules, Pylint rules that are enabled but already covered by Ruff rules,
# and the Ruff rules not enabled yet that match enabled Pylint rules.
#
# Largely based on https://github.com/astral-sh/ruff/issues/970
import re
import subprocess
from collections.abc import Mapping, Sequence
@pcorpet
pcorpet / use_dict_literal.py
Created June 20, 2023 05:27
Converts all python files to use dict literals instead of a function.
import libcst as cst
import os
def process_file(file_path):
# Read the content of the file
with open(file_path, "r") as file:
code = file.read()
# Parse the code file into a CST
@pcorpet
pcorpet / open-job-groups.json
Created July 12, 2019 15:10
Snippet of our Open Data on job groups
"growth20122022": 0.11912225705329153,
"hasFreelancers": false,
"hollandCodeMajor": "S",
"hollandCodeMinor": "C",
"inAWorkplace": "dans une structure d'accompagnement",
"inDomain": "dans le social",
"is_diploma_strictly_required": true,
"jobBoards": [
{
"filters": [
@pcorpet
pcorpet / job.proto
Created July 12, 2019 15:04
Snippet of the documentation of job group's data.
// How one would talk about various companies in this job group:
// In French: "chez Axa, Groupama ou ...", "à la BNP, au Crédit agricole".
// This data was manually built by Bayes Impact's Content Team over the years.
string at_various_companies = 24;
// Feminine version of what_i_love_about field.
// This data was manually built by Bayes Impact's Content Team over the years.
string what_i_love_about_feminine = 25;
// The (at most 11) top departements in terms of offer/demand ratio, in descending order.
@pcorpet
pcorpet / goal.tsx
Created July 12, 2019 14:57
Sample of Bob Emploi's code.
<WithNote
hasComment={true}
note={<React.Fragment>
{userYou('Tu ne trouves pas ton', 'Vous ne trouvez pas votre')} métier&nbsp;?
<ExternalLink style={{color: colors.BOB_BLUE, fontSize: 15, marginLeft: 3}}
href="https://airtable.com/shreUw3GYqAwVAA27">
Clique{userYou('', 'z')} ici pour l'ajouter
</ExternalLink>
</React.Fragment>}>
<FieldSet
@pcorpet
pcorpet / hash_lines.py
Last active July 11, 2017 15:13
Simple Python script to SHA-1 hash each line of a file
import hashlib
import sys
def hash_lines(inputfile, outputfile):
"""Hash all lines of the input file and populate the output."""
count = 0
with open(outputfile, 'wt') as output:
with open(inputfile, 'r') as input_lines:
for line in input_lines:
@pcorpet
pcorpet / hash.html
Created July 10, 2017 21:43
Simple page to SHA-1 hash many strings
<html>
<head>
<script src="https://cdn.rawgit.com/emn178/js-sha1/c724643d/src/sha1.js"></script>
<script>
function hashIt() {
var content = document.getElementById('content').value
document.getElementById('result').innerText =
content.split('\n').map(sha1).join('\n')
}
</script>
@pcorpet
pcorpet / schroedinger.py
Last active January 11, 2017 23:42
Minimal code to reproduce PyLint bug around infered, ignored, no-member
"""Minimal code to reproduce PyLint bug around infered, ignored, no-member."""
import os
class MyVeryOwnError(ValueError):
"""My Exception class."""
node = True
def main():