This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import subprocess | |
from concurrent.futures import ThreadPoolExecutor | |
from datetime import datetime | |
from pathlib import Path | |
from urllib.request import urlopen | |
REPOSITORIES = "https://github.com/pypi-data/data/raw/main/stats/repositories.json" | |
with urlopen(REPOSITORIES) as f: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This code can be put in any Python module, it does not require IPython | |
# itself to be running already. It only creates the magics subclass but | |
# doesn't instantiate it yet. | |
from IPython.core.magic import (Magics, magics_class, line_magic, | |
cell_magic, line_cell_magic) | |
import sqlite3 | |
# The class MUST call this class decorator at creation time | |
@magics_class | |
class MyMagics(Magics): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib | |
import json | |
from multiprocessing.dummy import Pool | |
from pathlib import Path | |
import urllib3 | |
DOWNLOAD_CACHE = Path("DownloadedMetadata") | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
import email.message | |
import re | |
from multiprocessing.dummy import Pool | |
import json | |
import traceback | |
import urllib3 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io | |
class LazyFile(io.RawIOBase): | |
def __init__(self): | |
self.pos = 0 | |
# Cache this as it may be costly to compute | |
self.end = self.get_size() | |
def get_size(self): | |
# Subclasses implement this | |
raise NotImplemented |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import collections.abc | |
import sqlite3 | |
class PersistentDict(collections.abc.MutableMapping): | |
def __init__(self, db=":memory:", table="dict"): | |
# Set to autocommit mode (isolation_level=None) | |
self.conn = sqlite3.connect(db, isolation_level=None) | |
if not table.isidentifier(): | |
raise ValueError(f"Table name {table!r} is not a valid identifier") | |
self.table = table |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""A dummy loader implementation. | |
This is a deliberate attempt to implement an absolutely minimal finder/loader | |
combination. | |
The spec is: | |
1. If I add an entry dummy:XXX to sys.path, then that entry will be picked | |
up by my finder and used to satisfy import requests for any modules | |
starting with 'XXX'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
twine | |
guideways | |
pygrib | |
openpyxl | |
amber | |
srl | |
pytrip | |
revisioning | |
geoSpatial | |
xresources |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use clap::Parser; | |
use std::fs::File; | |
use std::io; | |
use std::path::Path; | |
use std::io::BufRead; | |
use std::collections::HashMap; | |
use std::cmp::Reverse; | |
use crossbeam::thread; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = {} | |
data["extend"] = function (data, t) | |
for n, recipe in ipairs(t) do | |
for i, component in ipairs(recipe["ingredients"]) do | |
cname = component[1] or component["name"] | |
camt = component[2] or component["amount"] | |
print('"' .. recipe["name"] .. '","' .. cname .. '",' .. camt) | |
end | |
end | |
end |
NewerOlder