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
# `ssh -3 src.host.example:largefile dest.host.example:largefile` copies | |
# largefile from the source host to the destination, using the local machine | |
# as a relay. The file can be arbitrarily large. What if we don't have `scp`? | |
# We have | |
# - ssh connectivity from local machine to src.host.example | |
# - ssh connectivity from local machine to dest.dest.example | |
# - `ssh` client on local machine | |
# - `nc` command on remote machines | |
# - A large file called largefile on src.host.example |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
#!/usr/bin/env python3 | |
''' | |
Compute fs-verity digest for the given file(s). | |
''' | |
import argparse | |
import enum | |
import functools | |
import hashlib | |
import itertools |
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
#!/usr/bin/env python3 | |
''' | |
Construct a tarball from a blob summary | |
''' | |
import argparse | |
import tarfile | |
import ruamel.yaml |
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
#!/usr/bin/env/python3 | |
import hashlib | |
import sys | |
import tarfile | |
with tarfile.open(fileobj=sys.stdin.buffer, mode='r|') as tf: | |
for member in tf: | |
if member.isfile(): | |
with tf.extractfile(member) as mf: |
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
#define _DEFAULT_SOURCE | |
#define _GNU_SOURCE | |
#include <dirent.h> | |
#include <err.h> | |
#include <fcntl.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
/* Compile with |
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
def corange(end): | |
i = 0 | |
while i < end: | |
v = yield i | |
if isinstance(v, int): | |
end = v | |
i += 1 | |
for i in (r := corange(10)): | |
print(i) |
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
EVENS = object() | |
STOP = object() | |
class CM(): | |
def __init__(self, n=10): | |
print('__init__() called') | |
self.n = n | |
self._it = iter(range(n)) | |
self._evens = False |
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 os | |
import shutil | |
import string | |
import timeit | |
class FakeDirEntry: | |
def __init__(self, path): | |
self.path = path | |
self.name = path |
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
def copy_atomic(src, dst, follow_symlinks=True): | |
""" | |
Copy src file to dst atomically, via a temporary file that is renamed. | |
It is intended to be a drop in replacement for `shutil.copy2()`. | |
""" | |
if os.path.isdir(dst): | |
dst_dir = dst | |
dst_name = os.path.basename(src) | |
dst = os.path.join(dst, dst_name) |