Skip to content

Instantly share code, notes, and snippets.

View jaymecd's full-sized avatar

Nikolai Zujev jaymecd

View GitHub Profile
@jaymecd
jaymecd / signing-git-commits.md
Created April 29, 2022 11:35 — forked from phortuin/signing-git-commits.md
Set up a GPG key for signing Git commits on MacOS (M1)

Based on this blogpost.

To sign Git commits, you need a gpg key. GPG stands for GNU Privacy Guard and is the de facto implementation of the OpenPGP message format. PGP stands for ‘Pretty Good Privacy’ and is a standard to sign and encrypt messages.

Setting up

Install with Homebrew:

$ brew install gpg
@jaymecd
jaymecd / GNU-Make.md
Created February 12, 2021 21:51 — forked from rueycheng/GNU-Make.md
GNU Make cheatsheet
@jaymecd
jaymecd / rounding_decimals.md
Created January 1, 2021 01:03 — forked from jackiekazil/rounding_decimals.md
How do I round to 2 decimals in python?

How do I round to 2 decimals?

In python, you have floats and decimals that can be rounded. If you care about the accuracy of rounding, use decimal type. If you use floats, you will have issues with accuracy.

All the examples use demical types, except for the original value, which is automatically casted as a float.

To set the context of what we are working with, let's start with an original value.

Original Value

@jaymecd
jaymecd / main.go
Created August 18, 2020 19:03 — forked from pteich/main.go
Example for using go's sync.errgroup together with signal detection signal.Notify to stop all running goroutines
package main
import (
"context"
"errors"
"fmt"
"os"
"os/signal"
"syscall"
"time"
@jaymecd
jaymecd / python_decorator_guide.md
Created May 15, 2019 14:39 — forked from Zearin/python_decorator_guide.md
The best explanation of Python decorators I’ve ever seen. (An archived answer from StackOverflow.)

NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.


Q: How can I make a chain of function decorators in Python?


If you are not into long explanations, see [Paolo Bergantino’s answer][2].

@jaymecd
jaymecd / python-logging.md
Created May 8, 2019 07:31 — forked from mariocj89/python-logging.md
Understanding logging in Python

Logging trees

Introduction

When applications are running in production, they become black boxes that need to be traced and monitored. One of the simplest, yet main, ways to do so is logging. Logging allows us - at the time we develop our software - to instruct the program to emit information while the system is running that will be useful for us and our sysadmins.

@jaymecd
jaymecd / ssh-known-hosts-mgmt.sh
Created October 20, 2013 13:34 — forked from bradland/ssh-known-hosts-mgmt.sh
known_hosts management commands
# This is a short collection of tools that are useful for managing your
# known_hosts file. In this case, I'm using the '-f' flag to specify the
# global known_hosts file because I'll be adding many deploy users on this
# system. Simply omit the -f flag to operate on ~/.ssh/known_hosts
# Add entry for host
ssh-keyscan -H github.com > /etc/ssh/ssh_known_hosts
# Scan known hosts
ssh-keygen -f /etc/ssh/ssh_known_hosts -H -F github.com
@jaymecd
jaymecd / cf_create_or_update.py
Created April 3, 2019 09:20 — forked from svrist/cf_create_or_update.py
Update or create a CloudFormation stack given a name and template + params'
'Update or create a stack given a name and template + params'
from __future__ import division, print_function, unicode_literals
from datetime import datetime
import logging
import json
import sys
import boto3
import botocore
@jaymecd
jaymecd / redirectExample.go
Created October 11, 2016 21:20 — forked from d-schmidt/redirectExample.go
How to redirect HTTP to HTTPS with a golang webserver.
package main
import (
"net/http"
)
func redirect(w http.ResponseWriter, req *http.Request) {
http.Redirect(w, req,
"https://" + req.Host + req.URL.String(),
http.StatusMovedPermanently)
}
@jaymecd
jaymecd / cloudinit.yaml
Created June 19, 2018 18:56 — forked from ktstevenson/cloudinit.yaml
Cloud-init directive to add AWS SSM checking at boot time
#cloud-config
write_files:
- content: |
#!/bin/bash
REGION=$( curl -s http://169.254.169.254/latest/dynamic/instance-identity/document | python -c "import sys, json; print json.load(sys.stdin)['region']" )
aws --region $REGION ssm list-associations --max-items 1 > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "No privs to run Amazon SSM agent. Stopping..."
sudo stop amazon-ssm-agent
fi