Skip to content

Instantly share code, notes, and snippets.

@jrwarwick
jrwarwick / httpsminiserver.py
Last active August 6, 2019 21:11
HTTPS mini server will serve the current directory listing as downloadable files after auto-generating a self-signed SSL cert
#!/usr/bin/env python
# Based on the brilliant work of Jorge which I found here:
# https://jorge.fbarr.net/2017/06/11/simplehttpserver-with-ssl/
# He truly honors KISS principles. I just needed a little more automagicalness
# at the cost of a little more complexity and reduced portability.
# Oriented around the python 2.7 and openssl 1.1.1 world that some UNIX boxen are living in.
# Should handle even Chrome's more stringent Subject AltName requirements.
# Extra handy if started in a GNU screen session thus:
# screen -S httpsMiniServer /usr/local/httpsminiserver/httpsminiserver.py
import os.path
@jrwarwick
jrwarwick / apache_httpd_access_log_digest.sh
Created September 27, 2019 19:04
Apache httpd access_log digest in CSV, one-liner
egrep -hv '^::1 - -|"-" 408 - "-" "-"$' /var/log/httpd/access_log* | sed -e 's#\(https\?://[a-zA-Z0-9.\-]\+\)/##' | awk -F'[ "]+' '{print $4,$5","$3","$1","$6","$7}' | sed 's/\?/,/' | sed -e 's/^\[/"/' -e 's/\],/",/' | sed 's/:/","/' | egrep -hv '.png$|.jpg$|.gif$|.css$|.js$|.ico$' | egrep -hv 'OPTIONS,/fv/$|OPTIONS,HTTP/1.1$' | sort -u > /tmp/httpd_access_log_$(date +%Y%m%d).csv
@jrwarwick
jrwarwick / README.md
Last active October 16, 2019 06:13 — forked from insin/README.md
Extract Minecraft music

Extract Minecraft music (Windows-centric easy-cheezy edition)

As of 1.8, assets are stored by hash, which makes it fiddly to listen to Minecraft's amazing ambient soundtrack outside the game.

This script can be used to copy music files to appopriately-named and organised .ogg files for easier listening.

0. If you happen to have PowerShell 3.0, you might be able to just save and execute extract_mc_music.ps1 and then skip to step 5

1. Install Node.js. Actually, you don't even have to "install". You can just download the stand-alone zip archived version, extract it, and start a CMD shell in the subdirectory with node.exe in it.

2. Save extract_mc_music.js to your freshly extracted node directory.

@jrwarwick
jrwarwick / ps_ise_save_console_text.ps1
Created December 10, 2019 16:43
PowerShell ISE One-Liner: save Console pane text to file
#Maybe you just finished executing a bunch of stuff in the ISE script window and want to save the entire output
#maybe for a deployment log or something. Just drop this in scripting window, highlight, and execute selection.
#Could use this as an sort of alternative to Start-Transcript, too, but only in ISE execution situation.
$psise.CurrentPowerShellTab.ConsolePane.Text | Set-Content -Path $env:USERPROFILE\Downloads\ps_ise_execution_log_$((get-date).tostring("yyyyMMdd")).txt
@jrwarwick
jrwarwick / Microsoft.PowerShellISE_Profile.ps1
Created February 25, 2020 18:28
Microsoft.PowerShellISE_Profile.ps1
## $env:USERPROFILE\Documents\WindowsPowerShell\Microsoft.PowerShellISE_Profile.ps1
# Very low external dependencies edition
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add('Run with -Verbose',{ Invoke-Expression `
-Command ". '$($psISE.CurrentFile.FullPath)' -Verbose" }, `
'Ctrl+F5') | Out-Null
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add('Run with -Debug', { Invoke-Expression `
-Command ". '$($psISE.CurrentFile.FullPath)' -Debug" }, `
'Ctrl+F6') | Out-Null
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add('Launch Script Analyzer',{ Invoke-Expression `
@jrwarwick
jrwarwick / jira_ssl_certificate_update.ps1
Created May 7, 2020 18:00
JIRA (on Windows) SSL certificate replacement
#### https://confluence.atlassian.com/adminjiraserver085/running-jira-applications-over-ssl-or-https-981155619.html
#### Doc was helpful, but didn't quite cover all situations. Adapted the following from some tomcat-on-Linux work from the past.
## Assumes you are only updating our issued cert, not the whole CA trust chain.
## keystore password is available to you in some secrets repository
# From Admin Elevated PS session on JIRA server: #
$YYYY = $((get-date).tostring('yyyy'))
$YYYYMMDD = $((get-date).tostring('yyyyMMdd'))
$ENV:PATH += ";C:\Program Files\Atlassian\JIRA\jre\bin\;"
$jirakeystorefile = "C:\Program Files\Atlassian\Application Data\JIRA\jira.jks"
$wildcardcertstorefile = "\\resourceserver\share\path\to\new\Certificates\${YYYY}\wildcard_CAsigned_cert_${YYYY}.pfx"
@jrwarwick
jrwarwick / Batch radio-ize.txt
Created June 2, 2020 21:19
Audacity Macro: radio comms effect - *krssht* roger, wilco *krsssht*
Macro_radio-ize:
ExportOgg:
ExportMp3:
@jrwarwick
jrwarwick / Downstream-gh-pages-refresh.sh
Last active June 22, 2020 18:29
Recipe to refresh upstream gh-pages branch
pushd `git rev-parse --show-toplevel`
git fetch
git checkout gh-pages
git pull
git branch -vv ; git status -vv
git worktree add ./omaster origin/master
cp -uv omaster/LICENSE .
cp -uv omaster/README.md .
@jrwarwick
jrwarwick / ssl_cert_expiry_check.sh
Last active December 9, 2020 19:35
SSL Cert Catalog with Expiry Checking
#!/usr/bin/bash
function monthnumber {
month=$(echo ${1:0:3} | tr '[a-z]' '[A-Z]')
MONTHS="JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC"
tmp=${MONTHS%%$month*}
month=${#tmp}
monthnumber=$((month/3+1))
printf "%02d\n" $monthnumber
}
@jrwarwick
jrwarwick / hero_condense.js
Created April 16, 2021 17:12
Simple partial collapse/condense of a Hero region in Oracle APEX
//prerequisite: assign a static ID to your hero region.
//gets offset and height for total displacement
var heroRegionStaticID = "#pageNavCards";
var bottomofpageNavCards = $(heroRegionStaticID).offset().top + $(heroRegionStaticID).outerHeight();
$(window).scroll(function(){
if($(window).scrollTop() > bottomofpageNavCards){
$("#t_Body_title h1").fadeOut();
$("#t_Body_title div.t-HeroRegion-col.t-HeroRegion-col--left").fadeOut();
}