Skip to content

Instantly share code, notes, and snippets.

@mikequentel
mikequentel / rn.sh
Last active November 24, 2020 18:11
rn.sh -- git mv to rename files by a source pattern and an expected output pattern
#!/bin/bash
# based on:
# https://stackoverflow.com/questions/9984722/git-rename-many-files-and-folders
OLD_PATTERN=$1
NEW_PATTERN=$2
for file in `git ls-files | grep "$OLD_PATTERN"`; do git mv -k $file `echo $file | sed -e "s|$OLD_PATTERN|$NEW_PATTERN|g"`; done
@mikequentel
mikequentel / set_credentials.sh
Created October 1, 2020 12:59
bash script to set credentials as environment variables
if [ -z "${MY_USERNAME}" ]; then
echo -n "Enter MY_USERNAME: "
read -r MY_USERNAME
echo
fi
if [ -z "${MY_PASSWORD}" ]; then
echo -n "Enter MY_PASSWORD: "
read -r -s MY_PASSWORD
echo
fi
@mikequentel
mikequentel / docker-compose.yml
Last active September 25, 2020 20:24
Grafana and Prometheus docker-compose.yml
version: '3'
services:
prometheus:
image: prom/prometheus:latest
restart: unless-stopped
ports:
- "9090:9090"
volumes:
- /home/${USER}/opt/prometheus/data:/opt/prometheus/data:rw
# https://blogs.technet.microsoft.com/heyscriptingguy/2011/11/13/use-powershell-to-quickly-find-installed-software/
# Example finding location of 7-zip
$computername=(get-childitem -path env:computername).value
$UninstallKey="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
$reg=[microsoft.win32.registrykey]::OpenRemoteBaseKey('LocalMachine',$computername)
$regkey=$reg.OpenSubKey($UninstallKey)
$subkeys=$regkey.GetSubKeyNames()
$array = @()
  • Examples:
PS C:\Users\jenkins> get-wmiobject Win32_Product | Format-Table IdentifyingNumber, Name, LocalPackage

IdentifyingNumber                                                            Name                                                                         LocalPackage
-----------------                                                            ----                                                                         ------------
{B862B671-59FD-7457-AFA0-C738FB7ABD60}                                       Windows SDK Intellidocs                                                      C:\Windows\Installer\3641b758.msi
{90120000-0021-0000-0000-0000000FF1CE}                                       Microsoft Office Visual Web Developer 2007                                   C:\Windows\Installer\181667b6.msi
{90120000-0021-0409-0000-0000000FF1CE}                                       Microsoft Office Visual Web Developer MUI (English) 2007                     C:\Windows\Installer\181667af.msi
  • get last commit hash (full) git log -1 --pretty=format:%H
@mikequentel
mikequentel / ubuntu_build_essential.sh
Created March 9, 2017 20:43
ubuntu_build_essential.sh
#!/bin/bash
# http://askubuntu.com/questions/232200/how-do-i-install-development-tools-for-12-10
sudo apt-get install linux-headers-$(uname -r) build-essential
---
# Assuming there is a roles pattern in use,
# including subdirectory roles with
# roles/vars/main.yml (for storing variables in roles/vars/main.yml)
# and roles/example/main.yml
#
# top-level playbook example.yml looks like:
# ---
#
#- hosts: myhost
@mikequentel
mikequentel / get_variables.sh
Created February 13, 2017 14:48
Get variables for localhost in Ansible.
#!/bin/bash
ansible all -i localhost, -c local -m setup
@mikequentel
mikequentel / rpm-digital-signature.sh
Last active November 1, 2016 21:58 — forked from fernandoaleman/rpm-digital-signature.sh
How to sign your custom RPM package with GPG key
# How to sign your custom RPM package with GPG key
#
# Many thanks to Fernando Aleman <faleman@email.com> for this gist!
# https://gist.github.com/fernandoaleman/1376720
#
# Step: 1
# Generate gpg key pair (public key and private key)
#
# You will be prompted with a series of questions about encryption.
# Simply select the default values presented. You will also be asked