Skip to content

Instantly share code, notes, and snippets.

@paulmallon
paulmallon / maintenance.sql
Last active February 29, 2024 06:54
Some PostgreSQL maintenance queries
--- Get the names of databases and the age of their oldest unfrozen transaction ID (datfrozenxid)
SELECT datname, age(datfrozenxid)
FROM pg_database
ORDER BY age(datfrozenxid) desc
limit 20;
--- Get list of regular tables, including their size, age of the oldest unfrozen transaction ID (xid_age),
-- number of dead tuples, and timestamps for the last manual and automatic VACUUM and ANALYZE operations.
SELECT ns.nspname AS schema_name,
@paulmallon
paulmallon / zenburn.sh
Created February 2, 2021 08:33
terminal color-theme-zenburn - author: sonatard
echo -ne '\e]12;#BFBFBF\a'
echo -ne '\e]10;#DCDCCC\a'
echo -ne '\e]11;#3F3F3F\a'
echo -ne '\e]4;0;#3F3F3F\a'
echo -ne '\e]4;1;#705050\a'
echo -ne '\e]4;2;#60B48A\a'
echo -ne '\e]4;3;#DFAF8F\a'
echo -ne '\e]4;4;#506070\a'
echo -ne '\e]4;5;#DC8CC3\a'
echo -ne '\e]4;6;#8CD0D3\a'
@paulmallon
paulmallon / gopro.sh
Created May 10, 2020 02:51
gopro bash script
#!/bin/bash
curl "http://10.5.5.9/gp/gpControl/setting/62/2400000"
#stream bitrate
curl "http://10.5.5.9/gp/gpControl/setting/62/1000000"
# 720
curl "http://10.5.5.9/gp/gpControl/setting/64/4"
Get-DnsClientCache | where {$_.entry -like "*platform*" } |fl -Property entry, data
@paulmallon
paulmallon / Get-GitRepo.ps1
Created November 21, 2019 20:15
Powershell function to clone a git repository with tracking of all remote branches.
function Get-GitRepo {
param(
[Parameter(Position=0, Mandatory)]
$url,
[Parameter()]
[switch]
$DoNotTrackRemoteBranches
)
@paulmallon
paulmallon / Start-ConsoleDecompiler.ps1
Created November 2, 2019 21:25
Jetbrains Java Console Decompiler
$basePath = "C:\src\runtimeService-unpacked"
$targetPath = "c:\src\decompile"
$decompilerPath = "C:/Program Files/JetBrains/IntelliJ IDEA 2019.2.3/plugins/java-decompiler/lib/java-decompiler.jar"
$decompilerClass = "org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler"
Get-ChildItem $basePath *.class -Recurse | ForEach-Object {
java -cp $decompilerPath $decompilerClass `
@paulmallon
paulmallon / Get-GitlabProjects.ps1
Last active February 20, 2023 00:03
Powershell script for Gitlab REST API - A quick solution to clone selected (by id or name) or all repositories from the projects returned by API and setup git to track all remote branches. References: Gitlab Projects API: https://docs.gitlab.com/ee/api/projects.html Git doc: https://docs.gitlab.com/ee/api/projects.html
#
# Gitlab clone script
#
# Author: PM
# Date: 2019-10-18#
#
[CmdletBinding(DefaultParameterSetName = 'all')]
param (
[Alias('ID')]
[Parameter(ParameterSetName="id")]
@paulmallon
paulmallon / appendix.slq
Last active October 13, 2020 13:23
SQL snippets for "PostgreSQL - A maintenance and performance primer"
/**
Title: SQL snippets for "PostgreSQL - A maintenance and performance primer"
Author: PM - 2019
*/
----------------------------------------------------
-- Query to find unused indexes
SELECT s.schemaname,
@paulmallon
paulmallon / Gopro_live_stream.ps1
Last active February 17, 2019 14:00
Gopro 4 Hero Silver and Black live stream via ffplay in powershell
$ffplay = "c:\Users\PM\Desktop\ffmpeg-4.1-win64-static\bin\ffplay.exe"
function Send-UdpDatagram {
Param ([string] $EndPoint,
[int] $Port,
[string] $Message)
$IP = [System.Net.Dns]::GetHostAddresses($EndPoint)
$Address = [System.Net.IPAddress]::Parse($IP)
@paulmallon
paulmallon / chocolatey_install.ps1
Last active February 19, 2019 08:23
Install chocolatey via powershell
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))