Skip to content

Instantly share code, notes, and snippets.

@dkrusky
dkrusky / docker-install
Last active March 22, 2024 20:05
Docker install for Ubuntu 22.04 and up
#!/bin/bash
# deal with pre-requisites
sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
# install public signature for docker repo and setup repo
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
@dkrusky
dkrusky / tar.gz.extractor.cs
Created July 27, 2022 16:13
Pure c# class to extract files from .tar.gz files in memory. Expects a byte array of the file to extract.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Text;
using System.Threading.Tasks;
public class TarGzExtractor
{
@dkrusky
dkrusky / autofill.js
Created September 12, 2020 14:38
Automatically fill out a webform UI with test data. (supports: select, text, checkbox, textarea, radio)
// tested with jQuery 3.x
$(document).ready(function(){
$("[name^=entry]").each(function(){
switch($(this).prop("type")) {
case "radio":
$(this).prop("checked", true);
break;
case "checkbox":
$(this).prop("checked", true);
break;
@dkrusky
dkrusky / pfx2pem.sh
Created August 20, 2020 16:31
Command line script to convert pfx with private key to pem format for Apache/nginx
#!/bin/bash
if [ "$#" -lt 1 ]; then
echo "
Command Syntax:
pfx2pem <cert> <optional:password>
"
@dkrusky
dkrusky / setup.sh
Last active August 18, 2020 13:59
Script to assist in post installation of minimal secure setup for Debian.
#!/bin/bash
# ************************************
# * SETTINGS *
# ************************************
FIREWALL_DYNDNS="";
FIREWALL_GEOIP_ACCOUNT="";
FIREWALL_GEOIP_LICENSE="";
# Set value to 1 to install that feature. Otherwise set to 0
@dkrusky
dkrusky / setup.sh
Created August 6, 2020 21:04
Debian post-install core configuration script with firewall, mysql, php, composer, and nvm.
#!/bin/bash
# ************************************
# * SETTINGS *
# ************************************
FIREWALL_DYNDNS="";
FIREWALL_GEOIP_ACCOUNT="";
FIREWALL_GEOIP_LICENSE="";
# Set value to 1 to install that feature. Otherwise set to 0
@dkrusky
dkrusky / hmac.java
Created January 27, 2019 10:38
hmac
// API details
String APIKey = "xxxxxxx";
String APISecret = "xxxxxxx";
String APIEndpoint = "https://www.domain.com/api/";
String APIVersion = "1.0";
// an example API call
String action = "/client/authenticate/user/pass/0/xxxx"
// build complete API call
@dkrusky
dkrusky / configure-debian-9-linode.sh
Last active December 23, 2018 02:41
Configure fresh Debian 9 on Linode for hosted site with SSL, firewall, mysql, apache2, and php7.2-fpm
#!/bin/bash
# set the dyndns name you want to allow access from
dyndns="testing.noip.me"
# set the domain you will be using
domain="testing.com"
# set the email address for letsencrypt
email="info@testing.com"
@dkrusky
dkrusky / wp-config.php
Created December 22, 2018 00:23
Better WordPress Config (All customization's available)
<?php
/* Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') ) { define('ABSPATH', dirname(__FILE__) . '/'); }
/* Debug Mode */
error_reporting(E_ALL);
@ini_set('display_errors', false );
define( 'WP_DEBUG', false );
define( 'WP_DEBUG_LOG', false );
define( 'WP_DEBUG_DISPLAY', false );
@dkrusky
dkrusky / get-letsencrypt-key-pin.sh
Last active December 20, 2018 20:57
LetsEncrypt get sha256 keypin headers for HSTS/HPKP apache2
#!/bin/bash
HPKP=`openssl x509 -in /etc/letsencrypt/live/"$1"/cert.pem -pubkey -noout | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | openssl enc -base64`
echo "<IfModule mod_headers.c>"
echo " Header Always set Strict-Transport-Security \"max-age=31536000; includeSubdomains; preload\" env=HTTPS"
echo " Header always set Public-Key-Pins \"pin-sha256=\\\"$HPKP\\\"; max-age=5184000"
echo "</IfModule>"