Skip to content

Instantly share code, notes, and snippets.

@EarthmanT
EarthmanT / aws_mfa.py
Created Sep 10, 2020
Create MFA Session Token and List s3 Buckets
View aws_mfa.py
import os
import boto3
import pyotp
def get_mfa_session_token(long_term_aws_key,
longterm_aws_secret,
mfa_arn,
one_time_password,
token_ttl=900):
View gist:517de9ed6a832bb192f097190af164ef
--stage1
-f lib2to3.fixes.fix_getcwdu
-f lib2to3.fixes.fix_long
-f lib2to3.fixes.fix_nonzero
-f lib2to3.fixes.fix_input
-f lib2to3.fixes.fix_raw_input
-f lib2to3.fixes.fix_itertools
-f lib2to3.fixes.fix_itertools_imports
-f lib2to3.fixes.fix_exec
-f lib2to3.fixes.fix_operator
View gist:351dfdd817bebe454fe246217537589f
-f lib2to3.fixes.fix_apply
-f lib2to3.fixes.fix_except
-f lib2to3.fixes.fix_exitfunc
-f lib2to3.fixes.fix_funcattrs
-f lib2to3.fixes.fix_has_key
-f lib2to3.fixes.fix_idioms
-f lib2to3.fixes.fix_intern
-f lib2to3.fixes.fix_isinstance
-f lib2to3.fixes.fix_methodattrs
-f lib2to3.fixes.fix_ne
View gist:bedbfa6b3923b68d40e8d8360949da42
> futurize -wn --stage1 my_code
RefactoringTool: Skipping optional fixer: idioms
RefactoringTool: Skipping optional fixer: ws_comma
RefactoringTool: No changes to my_code/common.py
RefactoringTool: No changes to my_code/utils.py
RefactoringTool: No changes to my_code/module/functions.py
RefactoringTool: Refactored my_code/tests/test_functions.py
--- my_code/tests/test_functions.py (original)
+++ my_code/tests/test_functions.py (refactored)
@@ -1,3 +1,5 @@
@EarthmanT
EarthmanT / git_submodule_replacement.md
Created Feb 17, 2019 — forked from MJeorrett/git_submodule_replacement.md
Replace directory with git submodule
View git_submodule_replacement.md

These are the steps required to replace a directory with a submodule in git. Note: Assumes that you are currently working on branch called 'develop'

  1. Check out a new branch to make the changes on: git checkout -b creating-submodule
  2. delete directory to be replaced rm -rf path/of/directory/to/be/replaced
  3. git add . then git commit -m "removing local directory"
  4. add the submodule: git submodule add "https://github.com/repoName" path/of/directory/to/be/replaced
  5. git add . then git commit -m "adding submodule"
  6. delete the submodule directory if you don't do this git will throw a hissy when you try to checkout out develop to merge the changes in
  7. git checkout develop
  8. pull the submodule back into the local repo: git submodule foreach git fetch --tags then git submodule update --init --recursive
View Update execution
# Assuming you are using a Python shell like ipython.
# Create a Virtual env: `mktmpenv`
# Install Cloudify: `pip install cloudify`
# Open ipython: `ipython`.
from cloudify_rest_client import CloudifyClient
from copy import deepcopy
import json
manager_ip = '106.105.105.105' # Set your own value here.
@EarthmanT
EarthmanT / update_provider_context.py
Last active Aug 30, 2017
Update Cloudify Manager Provider Context (4.1.1) - Modify Task Retries/Task Retry Interval/Agent Key Path/etc
View update_provider_context.py
# Assuming you are using a Python shell like ipython.
# Create a Virtual env: `mktmpenv`
# Install Cloudify: `pip install cloudify`
# Open ipython: `ipython`.
from cloudify_rest_client import CloudifyClient
from copy import deepcopy
import json
manager_ip = '106.105.105.105' # Set your own value here.
@EarthmanT
EarthmanT / openstack_vm_with_docker.yaml
Created Feb 5, 2017
Create Openstack VM and Install Docker
View openstack_vm_with_docker.yaml
node_templates:
docker:
type: cloudify.nodes.Root
interfaces:
cloudify.interfaces.lifecycle:
create:
implementation: scripts/docker/install.py
start:
implementation: scripts/docker/bootstrap.py
@EarthmanT
EarthmanT / site.pp
Last active Aug 29, 2015
Nodecellar Site PP
View site.pp
class { '::mongodb::globals':
manage_package_repo => true,
}->
class { '::mongodb::server':
}->
class { '::mongodb::client':
}->
class { '::nodejs':
nodejs_dev_package_ensure => 'present',
View HAProxyCollector
interfaces:
cloudify.interfaces.monitoring:
start:
implementation: diamond.diamond_agent.tasks.add_collectors
inputs:
collectors_config:
HAProxyCollector:
config:
enabled: True
url: http://127.0.0.1:9000/haproxy_stats;csv