Skip to content

Instantly share code, notes, and snippets.

@MatthewJDavis
MatthewJDavis / slow-ubuntu-boot.sh
Last active January 29, 2020 23:29
Troubleshooting a slow ubuntu 18.04 boot time
# boot time, kernel and user space
systemd-analyze
# time critcal chain of units
systemd-analyze critical-chain
# prints list of all units ordered by time they took to initialise.
systemd-analyze blame
#Fix - removed faulty network from kvm virtual machine. Went from 5 min in user space (network.service) to 11 seconds. /etc/network/interfaces
@MatthewJDavis
MatthewJDavis / ssl.sh
Created January 15, 2020 16:22
ssl commands
#pfx to pem - extract private key and public cert
openssl pkcs12 -in file.pfx -nocerts -out privatekey.pem -nodes
openssl pkcs12 -in file.pfx -nokeys -out publiccert.pem -nodes
# view cert information
openssl x509 -in publiccert.pem -text
@MatthewJDavis
MatthewJDavis / update-tag.sh
Created January 15, 2020 15:53
Update tag to new git commit
# move existing git tag to different commit.
git log --pretty=oneline
git tag -a v1.0.0 12345j -f
git push origin --tags -f
@MatthewJDavis
MatthewJDavis / teamcityEnvVars.ps1
Last active January 3, 2020 20:49
TeamCity windows env vars
# change location of log files
[Environment]::SetEnvironmentVariable("TEAMCITY_LOGS_PATH", "D:\logs", "Machine")
# set memory of jvm for teamcity to use
[Environment]::SetEnvironmentVariable("TEAMCITY_SERVER_MEM_OPTS", "-Xmx10g", "Machine")
# Set data directory location
[Environment]::SetEnvironmentVariable("TEAMCITY_DATA_PATH", "D:\DataDir\", "Machine")
@MatthewJDavis
MatthewJDavis / venvwrapper.sh
Created November 30, 2019 20:14
install virtualenvwarpper for python ubuntu 18.04
# https://realpython.com/python-virtual-environments-a-primer/
sudo pip3 install virtualenvwrapper
vim ~/.bashrc
# Python virtual env wrapper settings
export WORKON_HOME=$HOME/Documents/python/venvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source /usr/local/bin/virtualenvwrapper.sh
@MatthewJDavis
MatthewJDavis / configure-centos7-ntfs.sh
Last active March 10, 2025 15:48
How to configure centos7 to mount ntfs volumes restored from AWS snapshot.
# https://wiki.centos.org/TipsAndTricks/NTFS
# http://manpages.ubuntu.com/manpages/xenial/man8/ntfsfix.8.html
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-using-volumes.html
# sudo required
sudo yum install epel-release -y
# install packages to mount and also fix ntfs drives if needed.
sudo yum install ntfs-3g -y
@MatthewJDavis
MatthewJDavis / Send-MDAzureADGuestInvitation.ps1
Last active October 25, 2020 06:00
Azure automation runbook to send guest invites to Azure AD
<#
.SYNOPSIS
Invite guest users to Azure Active Directory for demo application.
.DESCRIPTION
Users to be provided in CSV file with the headings 'username,email'.
Users will be be checked to see if they have been invited to Azure AD as a guest user previously. If there is already an invite, then no action will be take, if a user doesn't exist in Azure AD, then an invite will be sent.
Output will be logged to the job output in Azure.
.NOTES
https://docs.microsoft.com/en-us/azure/active-directory/b2b/b2b-quickstart-invite-powershell
#>
@MatthewJDavis
MatthewJDavis / azure-ubuntu-nginx-packer-image-gallery.json
Created October 19, 2019 16:35
Packer build for simple nginx installation with shared image gallery
@MatthewJDavis
MatthewJDavis / azure-ubuntu-nginx-packer.json
Created October 15, 2019 22:45
Packer build for simple nginx installation
{
"variables": {
"client_id": "{{env `ARM_CLIENT_ID`}}",
"client_secret": "{{env `ARM_CLIENT_SECRET`}}",
"subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}",
"tenant_id": "{{env `ARM_TENANT_ID`}}",
"managed_image_name": "{{env `MANAGED_IMAGE_NAME`}}",
"resource_group_name": "{{env `RESOURCE_GROUP_NAME`}}"
},
"builders": [
@MatthewJDavis
MatthewJDavis / azure-ubuntu-packer.json
Created October 14, 2019 00:29
Packer file to create ubuntu image in Azure
{
"variables": {
"subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}",
"managed_image_name": "{{env `MANAGED_IMAGE_NAME`}}",
"resource_group_name": "{{env `RESOURCE_GROUP_NAME`}}"
},
"builders": [
{
"type": "azure-arm",
"subscription_id": "{{user `subscription_id`}}",