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
# requirements: pandas, lxml | |
import pandas as pd | |
import sqlite3, time | |
from datetime import datetime | |
def fetch(): | |
df = pd.read_html('https://www.mersenne.org/report_recent_results/')[1] # first table is the login form | |
print(datetime.now().strftime('%c'), ">> Table fetched, data summary:") | |
print(df) |
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 enum | |
from io import RawIOBase | |
import os.path as osp | |
import xml.etree.ElementTree as xml | |
from collections import namedtuple | |
from pathlib import Path | |
from matplotlib import pyplot as plt | |
from matplotlib import cm, colors as mcolors | |
from itertools import islice, filterfalse |
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 snippet test rtree with spherical coordinate system. | |
// It will generate grid points of a cubic grid and store them in an rtree. | |
// And then query is done by find points within some (approximate) distance | |
// from query point. The query point can be specified by command line args. | |
// | |
// Commandline options: | |
// no args: query point (0, 0, 0) with radius 2 | |
// 3 args: query point (x, y, z) with radius 2 | |
// 4 args: query point (x, y, z) with radius r |
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
# cython: embedsignature=True, profile=True | |
from libc.math cimport log, sqrt | |
from libc.stdlib cimport rand, srand | |
from libc.time cimport time, time_t | |
import numpy as np | |
cimport numpy as np | |
cimport cython | |
from cython.view cimport array |
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
# See https://github.com/tcardonne/docker-github-runner for instructions | |
FROM tcardonne/github-runner:ubuntu-20.04 | |
RUN curl -L -o miniconda.sh https://repo.anaconda.com/miniconda/Miniconda2-latest-Linux-x86_64.sh | |
RUN bash miniconda.sh -b -p /miniconda | |
ENV CONDA="/miniconda" | |
ENTRYPOINT ["/entrypoint.sh"] | |
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] |
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 moduled provide patched version of builtin Zipfile class as in https://github.com/ThomasPinna/python_zipfile_improvement | |
You can have better speed when read several files from a zip file containing a large number of files | |
Modifications are marked with '===== PATCH =====' | |
""" | |
import io | |
import struct | |
from zipfile import * | |
from zipfile import (_CD_COMMENT_LENGTH, _CD_EXTRA_FIELD_LENGTH, | |
_CD_FILENAME_LENGTH, _CD_LOCAL_HEADER_OFFSET, |
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
# git: remove all remote branches except for master/main | |
git branch -r | grep -Eo 'cmpute/.*' | cut -c 8- - | xargs -n 10 git push cmpute --delete | |
# tar: unzip multiple tarballs in a row | |
find <INPUT_DIR> -name "*.tgz" | xargs tar -xz -C <OUTPUT_DIR> --checkpoint=10000 -f | |
# wavpack: compress DSD files | |
wavpack <INPUT_FILES> <OUTPUT_FILES> -h -m -v –-import-id3 | |
# slurm: Run a slurm interactive session with gpu on Greatlakes |
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 numpy as np | |
import msgpack | |
import msgpack_numpy | |
msgpack_numpy.patch() | |
import socket, time, os | |
from socket_helpers import recv_msg, send_msg | |
sout = socket.socket(family=socket.AF_UNIX, type=socket.SOCK_DGRAM) | |
sout.connect("/tmp/ros-ipc-data.sock") |
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 scripts calculates the Chebyshev approximation of Bessel functions | |
# | |
# Chebyshev approximation intro: | |
# - https://en.wikipedia.org/wiki/Approximation_theory#Chebyshev_approximation | |
# - https://mathworld.wolfram.com/ChebyshevApproximationFormula.html | |
# - http://www.chebfun.org/examples/cheb/ExactChebCoeffs.html | |
# - https://www.eeeguide.com/chebyshev-approximation/ | |
# | |
# Online modified Bessel function calculator | |
# - https://www.wolframalpha.com/input/?i=BesselI%5B0%2Cx%5D |
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 time import sleep | |
from tqdm import trange, tqdm | |
from random import random | |
from multiprocessing import Pool, Manager | |
from itertools import count | |
def _wrap_func(func, args, pool, nlock): | |
n = -1 | |
with nlock: | |
n = next(i for i,v in enumerate(pool) if v == 0) |