Skip to content

Instantly share code, notes, and snippets.

@MatthewJDavis
MatthewJDavis / simple_dedupe.py
Created April 9, 2020 02:16
dedupe projects in python
with open('./scheduled_builds.txt', 'r') as f:
lines = f.readlines()
print(lines)
project_list = []
for line in lines:
project_list.append(line)
@MatthewJDavis
MatthewJDavis / python_module_info.txt
Created March 7, 2020 02:08
Info on Python modules
# view module help from commandline
pydoc [module]
# within python
# list module attirbutes
>>> dir(module)
# view module help from within python
>>> help(module)
@MatthewJDavis
MatthewJDavis / remove_dynamodb.yml
Created February 27, 2020 22:56
snippet to remove dynamodb for blog post
- name: remove DynamoDB table
dynamodb_table:
name: "{{ item }}"
region: "{{ region }}"
state: absent
with_items: "{{ dynamodb_table_names }}"
@MatthewJDavis
MatthewJDavis / docker.sh
Last active March 7, 2020 02:03
Docker commands
# all images
docker image ls
# running containers
docker container ls
# all containers
docker container ps -a
# stop auto restart.
@MatthewJDavis
MatthewJDavis / fly.sh
Last active February 27, 2020 16:50
Concourse fly commands
#Login / change team
fly -t qa login -n main
#Unpause pipelines
fly -t qa unpause-pipeline -p matttestdb
#View jobs
fly -t qa jobs -p matttestdb
#Watch jobs output
@MatthewJDavis
MatthewJDavis / dynamodb_table_name_playbook.yml
Last active February 27, 2020 01:27
Get dynamodb table names with Ansible
---
- hosts: localhost
connection: local
gather_facts: no
vars:
dynamodb_table_names: []
feature: "matttestdb"
environment: "qa"
tasks:
- name: Set AWS region
@MatthewJDavis
MatthewJDavis / main.tf
Last active February 26, 2020 02:21
Create Azure VM with Terraform and use VM extension to run PowerShell script
# https://www.terraform.io/docs/providers/azurerm/r/virtual_machine.html
resource "azurerm_resource_group" "main" {
name = "${var.resource_group_name}"
location = "${var.location}"
tags = {
environment = "${var.tagValue}"
}
}
@MatthewJDavis
MatthewJDavis / init.ps1
Created February 26, 2020 01:54
Basic init with PowerShell script for demo
New-Item -Path 'C:\assets' -ItemType Directory
$text= @'
This file was provisioned with the azure virtual machine extension resource using Terraform.
https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/custom-script-windows
This is just a text file but a script similar to this could be run to register with a config managemnt solution, do basic
provisioning etc.
'@
Set-Content -Path 'C:\assets\provision.txt' -Value $text
@MatthewJDavis
MatthewJDavis / Set-TLSVersionToDefault.ps1
Created February 21, 2020 21:49
Set reg keys so PowerShell does not use TLS1.0 anymore to connect.
# https://docs.microsoft.com/en-us/security/solving-tls1-problem#update-windows-powershell-scripts-or-related-registry-settings
# use the “System Default” TLS versions
$command64 = 'reg add HKLM\SOFTWARE\Microsoft\.NETFramework\v4.0.30319 /v SystemDefaultTlsVersions /t REG_DWORD /d 1 /f /reg:64'
Invoke-Expression -Command $command64
$command32 = 'reg add HKLM\SOFTWARE\Microsoft\.NETFramework\v4.0.30319 /v SystemDefaultTlsVersions /t REG_DWORD /d 1 /f /reg:32'
Invoke-Expression -Command $command32
@MatthewJDavis
MatthewJDavis / date-filename.sh
Created February 19, 2020 01:44
Append date to filename linux
cp /etc/ansible/ansible.cfg /etc/ansible/ansible.cfg-$(date +%F)