start new:
tmux
start new with session name:
tmux new -s myname
#!/usr/bin/env bash | |
# https://stackoverflow.com/questions/4254389/git-corrupt-loose-object | |
# https://git.kernel.org/pub/scm/git/git.git/tree/Documentation/howto/recover-corrupted-blob-object.txt?id=HEAD | |
# https://stackoverflow.com/questions/39409252/how-to-fix-git-error-head-invalid-reflog-entry-xxxxxxxxxxxxxxxx | |
find .git/objects/ -size 0 -exec rm -f {} \; | |
git reflog expire --stale-fix --all | |
git gc --aggressive --prune=now | |
git fsck --full |
#!/usr/bin/env bash | |
# Copyright 2020 Darren Weber | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"). You may not | |
# use this file except in compliance with the License. A copy of the License is | |
# located at | |
# | |
# http://aws.amazon.com/apache2.0/ | |
# |
# see https://stackoverflow.com/questions/47177538/installing-miniconda-on-alpine-linux-fails | |
# adapted from https://github.com/Docker-Hub-frolvlad/docker-alpine-miniconda3 | |
# depends on ./alpine/glibc* already downloaded in the git repo | |
# https://github.com/docker-library/docker/blob/master/19.03/Dockerfile | |
# based on alpine:3.11 | |
image: docker:19.03.6 | |
# image: python:3.6-stretch | |
variables: |
# Since dict.merge() returns None on success, the | |
# statement can be followed with an 'or' expression | |
# to return the updated dict and assign it, return | |
# or yield the merged dict. | |
x = {1:'a'} | |
y = {2:'b'} | |
x.update(y) or x | |
# {1: 'a', 2: 'b'} |
From https://stackoverflow.com/questions/12569452/how-to-identify-numpy-types-in-python
Note that the type(numpy.ndarray)
is a type
itself and watch out for boolean and scalar types. Don't be too discouraged if it's not intuitive or easy, it's a pain at first.
See also:
>>> import numpy as np
# Thanks to: | |
# https://gist.github.com/bastman/5b57ddb3c11942094f8d0a97d461b430 | |
# Volumes | |
# https://github.com/chadoe/docker-cleanup-volumes | |
#docker volume rm $(docker volume ls -qf dangling=true) | |
#docker volume ls -qf dangling=true | xargs -r docker volume rm | |
#docker volume rm $(docker volume ls -q -f 'dangling=true') |
# load and parse a requirements.txt file | |
def parse_requirement(requirement, excludes): | |
lib = requirement.strip().split('#')[0] # strip new lines and comments | |
if lib: | |
lib_name = re.split(r'[[<>=! ]+', lib)[0] | |
if lib_name in excludes: | |
return '' | |
return lib.strip() | |
return '' |
## Parse and print ISO 8601 with some help from dateutil [1] and pandas [2] | |
## [1] https://dateutil.readthedocs.io/en/stable/_modules/dateutil/parser/isoparser.html | |
## [2] https://pandas.pydata.org/pandas-docs/stable/generated/pandas.to_datetime.html | |
import dateutil | |
import pandas as pd | |
any_date = '20180716' | |
dt = dateutil.parser(any_date) | |
# dt -> datetime.datetime(2018, 7, 16, 0, 0) |