Skip to content

Instantly share code, notes, and snippets.

@Aluriak
Aluriak / members_to_followers.py
Created October 12, 2017 16:01
Asana automatic assignation of members on projects
"""Automatically add project members as followers of all tasks in the project"""
from types import SimpleNamespace
import asana
def access_workspace(w_name:str) -> SimpleNamespace:
workspaces = client.workspaces.find_all()
for workspace in workspaces:
# print(dir(workspace))
@Aluriak
Aluriak / linkinliner.py
Created October 11, 2017 16:37
Automatically build text with each printable letter as a unique link.
"""
usage: <text> <file containing one link per line>
"""
import sys
def produce(text:str, links:iter) -> str:
links = iter(links)
for char in text:
@Aluriak
Aluriak / tengger.py
Last active February 6, 2019 10:12
Extract all Tengger Cavalry music in their subdirs, well formatted
"""Extract all Tengger Cavalry music in their subdirs, well formatted
This assume that you have Tengger Cavalry's zipped album (whatever the format of the songs is)
in your working directory, along this script.
Works with albums downloaded from their website:
https://tenggercavalry.bandcamp.com/music
"""
@Aluriak
Aluriak / clitogui.py
Created July 4, 2017 15:09
clitogui poc
"""Proof of concept for Nedgang's clitogui project.
This code show how to extract very basic informations from
a argparse parser, with an example on the parser of another project.
At least the following features are not handled:
- nargs flag (default value is provided as is to argparse. See option --columns)
- action
- subparsers
- flags (see action_store in argparse doc)
@Aluriak
Aluriak / Makefile
Created February 20, 2017 12:55
Simple statistics about words found in /usr/share/dict
all:
python3 words.py
@Aluriak
Aluriak / comparison.py
Created February 15, 2017 11:00
Compare intention lists with condition on a set
from timeit import timeit
print('First case: with complex set building notation')
def integrated_complex():
N = 1000
return [e for e in range(N) if e in {i for i in range(N) if i%2}]
@Aluriak
Aluriak / bollobas.py
Created November 28, 2016 18:51
Generator of graphs of type described in Bollobas et al.
"""Script generating edge/2 ASP atoms.
The rendered graph follows the rule given in Bollobas et al.:
density roughly equals (3/2) * |V| ^ (3/2)
"""
import random
import itertools
@Aluriak
Aluriak / bench_stream_div.py
Created November 26, 2016 19:36
benchmark of stream division algorithms
"""
This is a benchmark for a common operation on data : divide a stream
in two distinct parts.
Benchmarks use three techniques, leading for the following results:
10^3 10^5 10^7 (data size)
one 0.01 2.58 286
two 0.03 3.4 339
@Aluriak
Aluriak / benchmark_intension_if_clause.py
Created November 25, 2016 17:28
Demonstration of the absence of optimisation on intension's if clause
"""
Demonstration of the absence of optimisation on following intension syntax:
n for n in data if no not in set(toignore)
Here, `set(toignore)` is built at each loop,
leading to the following output of this code:
one: 3.593955495998671
two: 3.5888819139945554
@Aluriak
Aluriak / genpass.py
Last active July 11, 2017 08:44
Genpass, dumb and simple generator of passwordable stream
"""Little password generator, with very small amount of features, but funny ones:
usage:
genpass.py # yield four lines
genpass.py <alphabet> [+<char to add>] [-<char to remove>]
exemple:
genpass.py
genpass.py numeric +@
genpass.py numeric -0 +0 # 0 included ; last is right