Skip to content

Instantly share code, notes, and snippets.

@bsolomon1124
bsolomon1124 / install_simp_rhel_8.sh
Created April 6, 2021 21:05
Attempt at installing SIMP on RHEL 8
sudo -s
dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
dnf install -y yum-utils
dnf install -y https://yum.puppetlabs.com/puppet-release-el-8.noarch.rpm
dnf install -y https://download.simp-project.com/simp-release-community.rpm
dnf install -y simp
@bsolomon1124
bsolomon1124 / deprecate_args.py
Created August 4, 2020 17:40
Easy way to deprecate arguments with argparse
import argparse
import warnings
class DeprecateAction(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
warnings.warn("Argument %s is deprecated and is *ignored*." % self.option_strings)
delattr(namespace, self.dest)
>>> b"Added in d0b1708f".hex()
'416464656420696e206430623137303866'
@bsolomon1124
bsolomon1124 / find.txt
Created May 5, 2020 12:27
Find - the good stuff
DESCRIPTION & SIGNATURE
Signature (minus some options you don't need):
find [starting-point...] [expression]
GNU find searches the directory tree rooted at each given `starting-point` by
evaluating the given `expression` from left to right.
If no `starting-point` is specified, `.` is assumed.
function greet(person: string) {
return "Hello, " + person;
}
console.log(greet("you"));
console.log(greet([1, 2, 3]));
module.exports = {
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
};
@bsolomon1124
bsolomon1124 / findscripts.sh
Last active March 31, 2020 20:04
Recursive-find shell scripts, including no-extensions with shebang
#!/bin/sh
{
grep -rlE '^#!\s?/(usr/)?bin/(env\s+)?(sh|bash|fish|zsh)' .
find . -type f \( -iname "*.bash" -o -iname "*.sh" -o -iname "*.zsh" -o -iname "*.fish" \)
} | tr "\n" " " | uniq
@bsolomon1124
bsolomon1124 / Dockerfile.django
Created March 23, 2020 20:22
Minimalistic Dockerfile for testing small Django features & quirks
FROM python:3.8-slim-buster
ARG DJANGO_VERSION='3.*'
ARG PROJECT_NAME='project'
ARG APP_NAME='app'
RUN set -ex \
&& python3 -m pip install --upgrade --no-cache-dir pip "Django==${DJANGO_VERSION}" \
&& django-admin startproject ${PROJECT_NAME} \
&& cd ${PROJECT_NAME} || exit 1 \
FROM ubuntu:bionic
ENV LANG C.UTF-8
RUN which pip || true
RUN set -ex \
&& apt-get update -y \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
wget \
ca-certificates \
@bsolomon1124
bsolomon1124 / subprocess.py
Created March 5, 2020 22:06
Backport of Python 3.8 subprocess for 2.7 with improvements
#!/usr/bin/env python2
"""Backport of Python 3.8 subprocess for 2.7 with improvements."""
from __future__ import print_function
__all__ = ("run",)
from subprocess import PIPE, Popen as _Popen27