Skip to content

Instantly share code, notes, and snippets.

Adrien Horgnies AdrienHorgnies

Block or report user

Report or block AdrienHorgnies

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@AdrienHorgnies
AdrienHorgnies / clear_snapshots.py
Last active May 3, 2019
get rid of directories which are not referenced by a symbolic link because they're useless in my use case
View clear_snapshots.py
#!/usr/bin/env python3
import argparse
import logging
import os
import re
from datetime import datetime
from subprocess import call
from tempfile import mkdtemp
@AdrienHorgnies
AdrienHorgnies / check_anagrams.py
Last active Apr 30, 2019
Interviews programming questions
View check_anagrams.py
def check(s1, s2):
return sorted(s1.lower()) == sorted(s2.lower())
@AdrienHorgnies
AdrienHorgnies / ds.py
Last active Apr 12, 2019
compute directory size recursively. Motivated by shell limitation of 1000 arguments.
View ds.py
#!/usr/bin/env python3
import argparse
import logging
import math
import os
from os.path import dirname
def main(directories):
measures = {}
@AdrienHorgnies
AdrienHorgnies / relink.py
Created Mar 26, 2019
Script to update symbolic links after republication (no longer used, here for posteriority)
View relink.py
@AdrienHorgnies
AdrienHorgnies / magnets.py
Created Mar 8, 2019
find magnets and add them to transmission
View magnets.py
import argparse
from selenium import webdriver
import time
from subprocess import run
def get_magnets(url):
browser = webdriver.Chrome()
browser.get(url)
@AdrienHorgnies
AdrienHorgnies / README.md
Last active Apr 12, 2019
a wrapper around argparse to handle configuration file
View README.md

confargparse

Extends argparse.ArgumentParser to make it able to take in values from a configuration file.

Beyond the added functionality it doesn't not modify the behaviour of argparse.ArgumentParser and can thus be used as a drop in replacement.

Why

You may want to provide values either to the CLI or by configuration file. And you don't want to check yourself if each value not provided to the CLI is present in the configuration file. And you also don't want the CLI to shout an error because it hasn't been provided an option when it is present in the configuration file.

How

You can’t perform that action at this time.