Skip to content

Instantly share code, notes, and snippets.

View matteodellamico's full-sized avatar

Matteo Dell'Amico matteodellamico

View GitHub Profile
@matteodellamico
matteodellamico / List concatenation benchmarking.ipynb
Created December 6, 2020 18:47
Quick evaluation of different idioms to concatenate lists in Python
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@matteodellamico
matteodellamico / lazylist.py
Created December 6, 2020 18:35
A quick&dirty approach to enable efficient `a + b + c + d + e` behavior in a list-like object
from collections.abc import MutableSequence
from itertools import chain
class LazyList(list):
def __add__(self, other):
return LazyListSum((self, other))
class LazyListSum(MutableSequence):
def __init__(self, params):
self.__params = params
Verifying my Blockstack ID is secured with the address 13DUELhFzJadHmZ1YpxYXnzHyZ1TbokAge https://explorer.blockstack.org/address/13DUELhFzJadHmZ1YpxYXnzHyZ1TbokAge
#!/usr/bin/env python3
from json import loads
from subprocess import Popen, PIPE
KILL_LIST = {IDS_OF_ANNOYING_PEOPLE} # find them by running telegram-cli --json interactively, or run this and watch their ids together with their screen name
tg = Popen(['telegram-cli', '-C', '--json'], stdin=PIPE, stdout=PIPE)
for line in tg.stdout:
@matteodellamico
matteodellamico / priority_dict.py
Created January 4, 2013 10:22
Priority dict: a priority queue with updatable priorities You may have needed a priority queue with the ability to change the priorities of elements that were in the queue. This recipe solves this problem in an efficient way. The priority queue is implemented as a dictionary, where keys are the items of the queue, and values are their priorities…
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit