Skip to content

Instantly share code, notes, and snippets.

View mherkazandjian's full-sized avatar

Mher Kazandjian mherkazandjian

  • Freelance consultant
  • The Netherlands
View GitHub Profile
@mherkazandjian
mherkazandjian / openssh_build.sh
Last active January 22, 2024 11:16
patched rpms for centos 7 for openssh CVE-2023-51385
#
# 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 \
#!/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
##################################################
#!/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
@mherkazandjian
mherkazandjian / miniconda_installer.sh
Last active May 3, 2024 10:32
miniconda batch/slient web installation wrapper that can be executed also without downloading/saving it to disk
#!/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
@mherkazandjian
mherkazandjian / Singularity-openfaom-2.4
Last active July 29, 2019 02:50
Singularity recipe for creating a OpenFOAM 2.4 container based on ubuntu 14.04
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
@mherkazandjian
mherkazandjian / subprocess_asycio_example.py
Last active May 11, 2022 22:53
async capture of stdout while another coroutine is running and doing stuff
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
@mherkazandjian
mherkazandjian / tar_util.py
Created March 22, 2018 17:07
snippet for extracting a tar (or .tar.gz file)
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
"""
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)
@mherkazandjian
mherkazandjian / parallel.py
Created February 14, 2017 02:03
pmap example
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".
@mherkazandjian
mherkazandjian / split_paths.py
Last active November 7, 2016 16:31
function that splits a path into all its components
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