Skip to content

Instantly share code, notes, and snippets.


Nikolai Zujev jaymecd

View GitHub Profile
jaymecd / main.go
Created Aug 18, 2020 — forked from pteich/main.go
Example for using go's sync.errgroup together with signal detection signal.Notify to stop all running goroutines
View main.go
package main
import (
jaymecd /
Created May 15, 2019 — forked from Zearin/
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 /
Created May 8, 2019 — forked from mariocj89/
Understanding logging in Python

Logging trees


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 /
Created Apr 3, 2019 — forked from svrist/
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 / cloudinit.yaml
Created Jun 19, 2018 — forked from ktstevenson/cloudinit.yaml
Cloud-init directive to add AWS SSM checking at boot time
View cloudinit.yaml
- content: |
REGION=$( curl -s | 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
jaymecd /
Created Jun 18, 2018 — forked from weavenet/
Delete all versions of all files in s3 versioned bucket using AWS CLI and jq.
set -e
echo "Removing all versions from $bucket"
versions=`aws s3api list-object-versions --bucket $bucket |jq '.Versions'`
markers=`aws s3api list-object-versions --bucket $bucket |jq '.DeleteMarkers'`
View python argparse subcommand
import argparse
from mock import Mock
m = Mock()
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers()
query_group = subparsers.add_parser('query')
add_group = subparsers.add_parser('add')
jaymecd / macapp.go
Created May 18, 2018 — forked from mholt/macapp.go
Distribute your Go program (or any single binary) as a native macOS application
View macapp.go
// Package main is a sample macOS-app-bundling program to demonstrate how to
// automate the process described in this tutorial:
// Bundling the .app is the first thing it does, and creating the DMG is the
// second. Making the DMG is optional, and is only done if you provide
// the template DMG file, which you have to create beforehand.
// Example use:
jaymecd / .bash_profile
Last active Mar 15, 2018 — forked from giuliocalzolari/.bash_profile
aws cli helper
View .bash_profile
# Place following snippets into ~/.profile, ~/.bash_profile or other similar file.
# auto-mfa
complete -W "$(ls -1 ~/.aws/*.mfa | awk -F "/" '{print $NF}' | sed -e 's/\.mfa$//')" mfa mfa_token
function mfa_token () {
oathtool --base32 --totp "$(cat ~/.aws/$1.mfa)"
function mfa () {
mfa_token "$1" | pbcopy # OSX only
jaymecd /
Created Feb 3, 2018 — forked from cvuorinen/
Deploy Button on Olimex A20-OLinuXino-LIME with Jenkins build status and capistrano deploy. More information here:
#!/usr/bin/env python
import os
import time
from pyA20Lime.gpio import gpio
from pyA20Lime.gpio import port
from autojenkins import Jenkins
### configration parameters
You can’t perform that action at this time.