Skip to content

Instantly share code, notes, and snippets.

View dazza-codes's full-sized avatar

Darren Weber dazza-codes

View GitHub Profile
@dazza-codes
dazza-codes / git_rescue.sh
Created December 6, 2022 00:34
git rescue
#!/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
@dazza-codes
dazza-codes / lambda_layer_publish.sh
Created August 6, 2020 00:57
Create or update an AWS lambda layer from zip files
#!/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/
#
@dazza-codes
dazza-codes / .gitlab-ci.yml
Created February 29, 2020 22:18
gitlab-CI with dind and miniconda3
# 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:
@dazza-codes
dazza-codes / tmux-cheatsheet.markdown
Created March 30, 2019 15:52 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@dazza-codes
dazza-codes / python_dict_from_merge.py
Created February 7, 2019 05:38
Python: get dict after a dict.merge()
# 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'}
@dazza-codes
dazza-codes / check_numpy_types.md
Last active March 16, 2019 05:06
Checking numpy types
@dazza-codes
dazza-codes / Conferences.md
Last active December 29, 2018 02:34
Conferences

Conferences

2014

MongoDB Days 2014

  • San Francisco
  • Dec 2014
@dazza-codes
dazza-codes / docker_clean.sh
Last active October 3, 2018 15:00
Bash utility to clean docker containers and images
# 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)