Skip to content

Instantly share code, notes, and snippets.

View LoveDuckie's full-sized avatar
🤓
Hacking mainframes

Luc Shelton LoveDuckie

🤓
Hacking mainframes
View GitHub Profile
@LoveDuckie
LoveDuckie / is_process_running.sh
Created June 23, 2023 10:34
A simple script for determining whether a process is running on the local system.
is_process_running() {
if [ -z "$1" ]; then
write_error "shared_functions" "The process ID was not defined as the first parameter."
fi
if ps -p $1 >/dev/null; then
return 0
fi
return 1
}
@LoveDuckie
LoveDuckie / get_certificate_fingerprint.sh
Created June 23, 2023 10:32
A simple shell script function for retrieving the fingerprint of a certificate. Useful for determining whether a certificate is already present in a keychain on macOS.
write_error() {
MSG=$2
echo -e "\033[1;31m$1\033[0m \033[0;37m${MSG}\033[0m" 1>&2
return 0
}
get_certificate_fingerprint() {
if [ -z "$1" ]; then
write_error "shared_functions" "The certificate file path was not defined."
return 1
@LoveDuckie
LoveDuckie / eurovision2023.gs
Created May 13, 2023 00:04
eurovision-2023.exe
function GetAllSheetNames(time) {
var out = new Array()
var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
for (var i=0 ; i<sheets.length ; i++) {
if (sheets[i].getName() != "Overview") {
out.push( [ sheets[i].getName() ] )
}
}
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}]
@=""
[HKEY_CURRENT_USER\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32]
@=""
@LoveDuckie
LoveDuckie / amifind.sh
Last active July 17, 2022 19:08 — forked from vancluever/amifind.sh
Get latest Ubuntu AMI ID for AMD64
#!/bin/sh
# Use AWS CLI to get the most recent version of an AMI that
# matches certain criteria. Has obvious uses. Made possible via
# --query, --output text, and the fact that RFC3339 datetime
# fields are easily sortable.
export AWS_DEFAULT_REGION=us-east-1
aws ec2 describe-images \
@LoveDuckie
LoveDuckie / nginx-webp-silverstripe-example.conf.template
Last active August 12, 2022 12:27
This NGINX configuration can be used with Silverstripe for automatically serving generated .webp image assets. You can read more about that here: https://blog.theloveduckie.codes/automatically-serve-webp-images-with-silverstripe-and-nginx
map $http_accept $webp_suffix
{
default "";
"~*webp" ".webp";
}
server
{
listen 80;
listen [::]:80;
@LoveDuckie
LoveDuckie / _config.php
Created February 28, 2022 13:41
A configuration snippet for integrating memcached caching support with SliverStripe.
<?php
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Core\Cache\MemcachedCacheFactory;
$cacheClient = new Memcached();
$cacheClient->addServer('your-memcached-server-hostname-goes-here', 11211);
$cacheFactory = new MemcachedCacheFactory($cacheClient);
Injector::inst()->registerService($cacheFactory, "SilverStripe\\Core\\Cache\\CacheFactory");
Injector::inst()->registerService($cacheFactory, "CacheFactory");
@LoveDuckie
LoveDuckie / nginx-default-server-configuration.conf
Last active July 5, 2021 23:35
A default server configuration for NGINX. Useful as a "catch-all" configuration when there's no server configuration available for a domain on the host that NGINX is running from. Read more: https://lucshelton.com/blog/configuring-a-default-server-for-nginx/
server {
listen 80 default_server;
listen [::]:80 default_server;
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
server_name_in_redirect off;
server_name default_server;
server_tokens off;
charset utf-8;
@LoveDuckie
LoveDuckie / openssl-self-signed-san-certificates
Created July 5, 2021 12:10
Default configuration to use when creating self-signed SAN SSL certificates for HTTPS. https://lucshelton.com/blog/configuring-a-default-server-for-nginx/
[req]
default_bits = 4096
distinguished_name = req_distinguished_name
req_extensions = v3_req
prompt = no
[req_distinguished_name]
name = Your Name Goes Here
countryName= Your Country Name Goes Here
stateOrProvinceName = Your State or Province Name Goes Here
ARG CUSTOM_BUILD_VERSION
ARG CUSTOM_BUILD_DATE
ARG CUSTOM_BUILD_UID
ARG NGINX_VERSION 1.20.1
FROM nginx:${NGINX_VERSION}-alpine AS builder
ARG CUSTOM_BUILD_VERSION
ARG CUSTOM_BUILD_DATE