Skip to content

Instantly share code, notes, and snippets.

View fpom's full-sized avatar

Franck Pommereau fpom

View GitHub Profile
@fpom
fpom / queues.py
Created February 17, 2022 15:07
Implementation of asyncio.queues.Queue for Brython
from collections import deque
from browser.aio import Future
class QueueEmpty (Exception) :
pass
class QueueFull (Exception) :
pass
class Queue (object) :
@fpom
fpom / LICENCE
Last active August 4, 2023 02:05
Animate C code and data structures for LaTeX/beamer (replaced with https://github.com/fpom/codanim)
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
@fpom
fpom / indedent.py
Created December 22, 2018 09:26
Add indent/dedent as explict text to ease the parsing of Python-like languages
import io
import token
import tokenize
NL = None
for num, name in token.tok_name.items() :
if name == "NL" :
NL = num
break
@fpom
fpom / DoNotTryThisAtHome.py
Last active May 3, 2017 14:12
Import module with standard name
import os, sys, imp
def stdimp (name) :
cwd = os.getcwd()
old = imp.new_module(name)
old.__dict__.update(sys.modules[name].__dict__)
for path in sys.path :
if path == cwd :
continue
try :

Keybase proof

I hereby claim:

  • I am fpom on github.
  • I am franckpommereau (https://keybase.io/franckpommereau) on keybase.
  • I have a public key whose fingerprint is 053B B213 5F47 3903 1170 F1FC BB39 038C F4F9 96F8

To claim this, I am signing this object:

@fpom
fpom / makecolors.py
Created September 5, 2016 09:47
Generate distinct colors as RGB triples
import numpy as np
import colorsys
def make_colors (num):
"Generate num disting colors as RGB triples"
for i in np.arange(0.0, 360.0, 360.0/num):
yield colorsys.hls_to_rgb(i/360.0, 0.7, 0.9)
@fpom
fpom / sci-hub.md
Created March 26, 2016 22:18
View on SCI-HUB
  1. Install Firefox extension Custom buttons: http://custombuttons.mozdev.org/

  2. Create a new button with the code below:

    url = content.document.location loadURI(url.protocol + "//" + url.hostname + ".sci-hub.io" + url.port + url.pathname)

  3. When you hit the paywall, click on the button and enjoy.

@fpom
fpom / getjazz.py
Created March 2, 2016 08:03
Get links from The David W. Niven Collection of Early Jazz Legends
# this is for Python 2.x
import urlparse
from pyquery import PyQuery as pq
url = "https://archive.org/details/davidwnivenjazz"
doc = pq(url)
todo = []
for a in doc("a[href]") :
@fpom
fpom / getjazz.sh
Created March 2, 2016 07:35
Get The David W. Niven Collection of Early Jazz Legends
# https://archive.org/details/Duke_Ellington_Tape_75_1959_Anatomy_of_a_Murder_Newport_Jazz_Festival_1959
wget --continue -O 'dl/Duke_Ellington_Tape_75_1959_Anatomy_of_a_Murder_Newport_Jazz_Festival_1959.zip' 'https://archive.org/compress/Duke_Ellington_Tape_75_1959_Anatomy_of_a_Murder_Newport_Jazz_Festival_1959'
# https://archive.org/details/Lionel_Hampton_Tape_3_1938-1939
wget --continue -O 'dl/Lionel_Hampton_Tape_3_1938-1939.zip' 'https://archive.org/compress/Lionel_Hampton_Tape_3_1938-1939'
# https://archive.org/details/Lionel_Hampton_Tape_1_1930-1937
wget --continue -O 'dl/Lionel_Hampton_Tape_1_1930-1937.zip' 'https://archive.org/compress/Lionel_Hampton_Tape_1_1930-1937'
# https://archive.org/details/Chet_Baker_Tape_2_1953-1956
wget --continue -O 'dl/Chet_Baker_Tape_2_1953-1956.zip' 'https://archive.org/compress/Chet_Baker_Tape_2_1953-1956'
# https://archive.org/details/Frank_Sinatra_Tape_1_1940
wget --continue -O 'dl/Frank_Sinatra_Tape_1_1940.zip' 'https://archive.org/compress/Frank_Sinatra_Tape_1_1940'
@fpom
fpom / followers.py
Created February 12, 2016 09:27
Follow your Twitter followers
import os.path, codecs
import twitter
api = twitter.Api(consumer_key="YOUR USER ID HERE",
consumer_secret="YOUR SECRET KEY HERE",
access_token_key="YOUR TOKEN KEY HERE",
access_token_secret="YOUR SECRET TOKEN HERE")
if os.path.isfile("followers.dump") :
with codecs.open("followers.dump", encoding="utf-8") as infile :