Skip to content

Instantly share code, notes, and snippets.

View jeffryang24's full-sized avatar

Jeffry Angtoni jeffryang24

View GitHub Profile
@jeffryang24
jeffryang24 / cli.py
Created July 21, 2018 04:06 — forked from mivade/cli.py
Using a decorator to simplify subcommand creation with argparse
from argparse import ArgumentParser
cli = ArgumentParser()
subparsers = cli.add_subparsers(dest="subcommand")
def argument(*name_or_flags, **kwargs):
"""Convenience function to properly format arguments to pass to the
subcommand decorator.
@jeffryang24
jeffryang24 / pre-commit.py
Created June 25, 2018 09:36
Git pre-commit hook to lint changed python files
#!/usr/bin/env python
"""
Lint python files before commit with flake8 and pep8 lint tools.
You can define lint settings in '.pep8' file in the project root.
Section '[pep8]' if for pep8 linter, and section '[flake8]' is for flake8.
INSTALL:
1. sudo pip install flake8 pep8
2. Save this file to '.git/hooks/pre-commit' file in your git repository
@jeffryang24
jeffryang24 / post_install.sh
Created June 23, 2018 05:33 — forked from waleedahmad/post_install.sh
Ubuntu post installation script for installing software of your choice.
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
else
#Update and Upgrade
echo "Updating and Upgrading"
apt-get update && sudo apt-get upgrade -y
@jeffryang24
jeffryang24 / simple_args_parsing.sh
Created June 12, 2018 10:51 — forked from jehiah/simple_args_parsing.sh
a simple way to parse shell script arguments
#!/bin/sh
#
# a simple way to parse shell script arguments
#
# please edit and use to your hearts content
#
ENVIRONMENT="dev"
@jeffryang24
jeffryang24 / backup.sh
Created May 30, 2018 12:37 — forked from arunk-s/backup.sh
Shell Script for taking Incremental Backup and store it at a remote place
# backup.sh
# The contents of this file are released under the GNU General Public License. Feel free to reuse the contents of this work, as long as the resultant works give proper attribution and are made publicly available under the GNU General Public License.
# By Arun Sori <arunsori94@gmail.com>
#For taking backup of the desired directory and store it at a remote place
#timestamp
time_stamp=`date`
#backup file name
@jeffryang24
jeffryang24 / rsync-incremental-backup.sh
Created May 28, 2018 10:58 — forked from morhekil/rsync-incremental-backup.sh
Shell script to handle incremental data backups with rsync. Optimised to handle large number of infrequently changing files, by using hard links to save on used disk space. For more details - http://localhost:4000/2014/01/12/automatic-backups-with-ruby-and-linux-shell-part-3/
#!/bin/bash
# Rsync based file backup script, with hard-linking enabled.
#
# Runtime options:
# -n - dry-run; do nothing, just display what is going to happen on a real run
# -v - verbose output; print out what is being backed up
#
# set to your rsync location
@jeffryang24
jeffryang24 / update-docker-compose.sh
Created May 14, 2018 17:19 — forked from jcberthon/update-docker-compose.sh
Downloading and installing/updating latest Docker Compose (command line)
#!/bin/bash
# Copyright 2017-2018 Jean-Christophe Berthon
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@jeffryang24
jeffryang24 / pip-upgrade.sh
Created April 16, 2018 11:51
pip recursive upgrade packages
#!/bin/bash
# Upgrade all pip outdated packages
pip install -U -r <(pip list --outdated --format=freeze | sed 's/==/>=/')
@jeffryang24
jeffryang24 / gpg-import-and-export-instructions.md
Created September 12, 2017 17:29 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...