Skip to content

Instantly share code, notes, and snippets.

@bsolomon1124
bsolomon1124 / game_of_life.py
Last active March 20, 2024 11:09
Conway's game of life in NumPy
"""NumPy/SciPy implementation of Conway's Game of Life.
https://bitstorm.org/gameoflife/
"""
import argparse
import curses
import getopt
import time
from itertools import repeat
@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)
@bsolomon1124
bsolomon1124 / timeit.py
Created June 21, 2018 14:40
Decorator version of `timeit.repeat()`
import functools
import gc
import itertools
from timeit import default_timer as _timer
_repeat = functools.partial(itertools.repeat, None)
def timeit(repeat=3, number=1000):
"""Decorator: prints time from best of `repeat` trials.
@bsolomon1124
bsolomon1124 / basic.py
Created July 11, 2018 15:49
Demonstrates different LogRecord attributes (formatters)
"""Demonstrates different LogRecord attributes (formatters).
https://docs.python.org/3/library/logging.html#logrecord-attributes
"""
import logging
# Notes
# -----
# pathname: this is relative!
# created: time in seconds since the epoch as a float
@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
>>> 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"
],
};