Skip to content

Instantly share code, notes, and snippets.

@rezemika
rezemika / easycrypt.py
Last active July 24, 2018 21:03
Outil de chiffrement et signature de message par GPG en ligne de commande
"""
Un petit script pour rendre plus intuitif le chiffrement et/ou
la signature d'un message avec GPG.
Dépendances :
$ pip3 install python-gnupg npyscreen humanfriendly
"""
# To package this into a standalone program, see "pyinstaller" (https://www.pyinstaller.org/): `pyinstaller easycrypt.py`.
@rezemika
rezemika / localized_names.py
Created April 21, 2018 15:51
Python - Weekdays and months in many locales
"""This file contains localized names of weekdays and months and the first day of week's index in 714 locales.
Shape:
{
str (locale's name): {
"days": list[str*7],
"months": list[str*12],
"first_week_day": int
},
...
@rezemika
rezemika / number.py
Created April 3, 2018 19:15
Python - Number to words
"""
This script returns a string of a number in letters (**in french**) from a positive integer.
$ python3 number.py 1254
mille deux-cent cinquante-quatre
It works for numbers from 0 to 999 999 999 999 (1 trillion minus 1).
"""
import sys
@rezemika
rezemika / pcs.json
Created November 16, 2017 15:22
Codes PCS 2003 et 2017-ESE de l'INSEE
{
"2003": [
{
"children": [
{
"children": [
{
"children": [
{
"children": [],
@rezemika
rezemika / join_notificator.py
Created October 27, 2017 18:55
Weechat join notificator
# To place in ~/.weechat/python/autoload/
import weechat
import pynotify
APP_NAME = "JoinNotificator"
AUTHOR = "rezemika"
__version__ = "0.1.0"
weechat.register(
@rezemika
rezemika / utils.py
Last active October 26, 2017 15:47
Some useful expressions in Python
"""
This gist contains some useful things which are frequently used in Python or are boring to copy by hand.
Index:
- L11-L45 : ANSI characters to color and format outputs to Linux terminals.
- L47-L100 : Weekdays and months names.
Feel free to post any idea or suggestion!
"""
@rezemika
rezemika / citeabook.py
Last active August 11, 2017 23:05
CiteABook: A simple script which outputs a formatted string citing a book from its ISBN.
# citeabook.py
#
# Licence AGPLv3 by rezemika.
#
import sys
import requests
import datetime
# TODO : Check ISBN.
@rezemika
rezemika / weechat_converter.py
Last active August 8, 2017 09:24
A simple tool to convert Weechat screenshots to pretty quotes.
#!/usr/bin/env python3
"""
Outputs to stdin a quote-like text from a Weechat screen.
How to use this script?
./weechat_converter.py --help
--aligned Aligns all reply starts
@rezemika
rezemika / HorizontalHistograms.py
Created June 6, 2017 18:25
String tables and horizontal histograms in Python3
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Table and HorizontalHistogram are two simple Python classes.
The first make it easy to use a table, allowing, for example,
to vertically align several string elements.
The second allows to create an ASCII art horizontal histogram