Skip to content

Instantly share code, notes, and snippets.

View jaymecd's full-sized avatar

Nikolai Zujev jaymecd

View GitHub Profile
@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 / amend-git-author.md
Created December 3, 2018 22:45
Amend GIT author within branch starting from COMMIT_ID

To reset commit author its required:

  1. to update default user name/email. (--global could added)
$ git config user.name example user
$ git config user.email example@email.com
  1. set checkpoint to keep orignal commit tree.
@jaymecd
jaymecd / pip_target_freeze.py
Created November 28, 2018 21:51
Get `pip freeze` packages for target directory, which was installed using `pip install -t <path>`
#!/usr/bin/env python
# RUN: pip_target_freeze.py <path>
from pip._vendor import pkg_resources
import sys
def find_on_path(path):
dists = pkg_resources.find_on_path(None, path)
dists = sorted(dists, key=lambda item: str(item))
@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
@jaymecd
jaymecd / delete_all_object_versions.sh
Created June 18, 2018 15:10 — forked from weavenet/delete_all_object_versions.sh
Delete all versions of all files in s3 versioned bucket using AWS CLI and jq.
#!/bin/bash
bucket=$1
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'`
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
jaymecd / macapp.go
Created May 18, 2018 06:07 — forked from mholt/macapp.go
Distribute your Go program (or any single binary) as a native macOS application
// Package main is a sample macOS-app-bundling program to demonstrate how to
// automate the process described in this tutorial:
//
// https://medium.com/@mattholt/packaging-a-go-application-for-macos-f7084b00f6b5
//
// 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
jaymecd / .bash_profile
Last active March 15, 2018 15:12 — forked from giuliocalzolari/.bash_profile
aws cli helper
# 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
jaymecd / deploy.py
Created February 3, 2018 20:40 — forked from cvuorinen/deploy.py
Deploy Button on Olimex A20-OLinuXino-LIME with Jenkins build status and capistrano deploy. More information here: http://cvuorinen.net/2015/10/building-a-deploy-button/
#!/usr/bin/env python
import os
import time
from pyA20Lime.gpio import gpio
from pyA20Lime.gpio import port
from autojenkins import Jenkins
### configration parameters
@jaymecd
jaymecd / php-fpm-cli
Created December 1, 2017 22:40 — forked from muhqu/php-fpm-cli
#!/bin/bash
#
# The MIT License (MIT)
#
# Copyright (c) 2014 Mathias Leppich <mleppich@muhqu.de>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell