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
# | |
# patched rpms for CVE-2023-51385 ( https://access.redhat.com/security/cve/cve-2023-51385 ) | |
# | |
mkdir workdir | |
docker run -it --rm -v $PWD/workdir:/root centos:7 | |
yum install -y \ | |
pam-devel \ | |
rpm-build \ | |
zlib-devel \ | |
wget \ |
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 bash | |
################################################## | |
# usage: | |
# $ ./install_fzf_rg.sh | |
# execute the script without saving it to disk: | |
# | |
# $ curl -s -L https://gist.github.com/mherkazandjian/a506af9858bbe44a9fbf5c21c9b15682/raw/install_fzf_rg.sh | bash -s | |
################################################## |
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 bash | |
################################################## | |
# usage: | |
# # quick install | |
# $ ./install_cmake.sh | |
# # quick install with a custom install path / prefix | |
# $ ./install_cmake.sh /opt/cmake | |
# execute the script without saving it to disk: | |
# $ curl -s https://gist.githubusercontent.com/mherkazandjian/fba54cd94316bfc1b1693a6ba2625f50/raw/2a1cefe9951bf6bd94910aefebb59d22eb85599c/cmake_installer.sh | bash |
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 bash | |
################################################## | |
# usage: | |
# $ ./install_miniconda.sh ~/apps/miniconda | |
# $ ./install_miniconda.sh ~/apps/miniconda --mamba | |
# $ ./install_miniconda.sh ~/apps/miniconda --installer latest | |
# $ ./install_miniconda.sh ~/apps/miniconda --upgrade --mamba | |
# $ ./install_miniconda.sh ~/apps/miniconda --installer latest --upgrade --mamba | |
# $ ./install_miniconda.sh ~/apps/miniconda --installer Miniconda3-py310_23.5.1-0-Linux-x86_64.sh --upgrade --mamba |
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
BootStrap: debootstrap | |
OSVersion: trusty | |
MirrorURL: http://us.archive.ubuntu.com/ubuntu/ | |
%post | |
sed -i 's/$/ universe/' /etc/apt/sources.list | |
apt-get update | |
apt-get clean | |
apt-get install -y --no-install-recommends locales | |
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen |
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 asyncio | |
import shlex | |
async def run_command(command: str): | |
""" | |
Coroutine that runs a command and captures the output as it is generated | |
The stdout output is collected in an async fashion one line at a time. | |
Each line is logged to the output for demonstration purposes. Once can |
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 tarfile | |
def extract_tar_gz_file(in_fpath: str, out_dir: str): | |
""" | |
Extract a zipped tar archive | |
:param in_fpath: the path to the .tar.gz file | |
:param out_dir: the path of the extracted content | |
""" |
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 split_to_uniform_ranges(n, n_parts): | |
""" | |
Split n into n_parts where the max difference among parts is 1 | |
:param int n: the number to be split | |
:param int n_parts: The number of parts with which n will be split | |
:return: n_part tuples that indicate the stat-end of the ranges | |
""" | |
n, n_parts = numpy.int32(n), numpy.int32(n_parts) |
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 | |
from multiprocessing import Process, cpu_count, Queue | |
def pmap(func, items, func_args=(), func_kwargs={}, n_workers=cpu_count()): | |
"""Maps the function "func" to each item in "items" in parallel using | |
threads. | |
:param callable func: A callable that takes "array" as a first positional | |
argument and returns an array that is the same size the input "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
def split_path(path): | |
"""split a path fully into its components | |
:param path: input path string | |
:return: list of the split path | |
.. todo:: see how to use generators with the yield statement | |
.. todo:: to replace the while loop | |
.. code-block:: python |