Skip to content

Instantly share code, notes, and snippets.

View andygock's full-sized avatar

Andy Gock andygock

View GitHub Profile
@andygock
andygock / github-pages-deploy.md
Last active September 13, 2024 08:12
Deploy dist to GitHub Pages

Deploying to GitHub Pages

Based on guide by Sangsoo Nam

Set up a branch named gh-pages in the repository. This branch will be used to deploy the site.

git checkout --orphan gh-pages
git reset --hard
git commit --allow-empty -m "Initial commit"

git checkout master

import getpass
import hashlib
import requests
# Function to get user password securely
def get_password():
password = getpass.getpass("Enter password: ")
return password
#
# Description: This script checks if a password has been found in any known data breaches using the Pwned Passwords API.
#
# Function to get user password securely
function Get-Password {
[Console]::Write("Enter password: ")
$password = Read-Host -AsSecureString
return $password
}
@andygock
andygock / README.md
Created March 23, 2024 08:31 — forked from asheroto/README.md
Strip PowerShell output that contains spinner, progress bar, or more than one empty line.

Strip-Progress

Strip PowerShell output that contains spinner, progress bar, or more than one empty line. Fixes download progress formatting by effectively removing extra space after the slash, often seen in winget (example 269 MB / 305 MB).

When to use

This function can be beneficial when you're capturing the output stream of a command, but don't want the extra characters in the text. See examples. Works great with winget.

Usage

#!/bin/bash
#
# Create list.txt with each repo name on a new line
#
# You can copy all the names from your GitHub repo page with the following command in the browser
# copy([ ...document.querySelectorAll("a[itemprop]")].map(a=>a.href.match(/.*\/(.*)$/)[1]).join("\n") + "\n")
#
# Or open settings, repositories, and copy the names from the list, this method below includes repos which you collaborate with, so you may need to just manually remove them
# copy([...document.querySelectorAll(".js-collaborated-repos a.mr-1")].map(n=>n.innerText.replace(/^.*\//,'')).join("\n"))
# Then run:
@echo off
rem Create list.txt with each repo name on a new line
rem
rem You can copy all the names from your GitHub repo page with the following command in the browser
rem copy([ ...document.querySelectorAll("a[itemprop]")].map(a=>a.href.match(/.*\/(.*)$/)[1]).join("\n") + "\n")
rem
rem Or open settings, repositories, and copy the names from the list, this method below includes repos which you collaborate with, so you may need to just manually remove them
rem copy([...document.querySelectorAll(".js-collaborated-repos a.mr-1")].map(n=>n.innerText.replace(/^.*\//,'')).join("\n"))
rem
rem Then run:

GPG Cheat Sheet

Written for GPG versions 2.x only.

List keys

List public keys

gpg --list-keys
@andygock
andygock / copy.js
Created July 24, 2020 14:42
JS function to copy string to clipboard in browser
const copy = str => {
const el = document.createElement("textarea");
el.value = str;
document.body.appendChild(el);
el.select();
document.execCommand("copy");
document.body.removeChild(el);
};
#!/bin/bash
#
# renew-letsencrypt-certificates.sh DOMAIN [EMAIL]
#
# Copy Let's Encrypt SSL certs from a remote public facing web server to local filesystem
# Look for changes, if any change, restarts the web service
# Useful for using Let's Encrypt with local internal servers, with custom DNS.
# Working "mail" command needed for email alerts
#
#!/bin/sh
# Flush tables
iptables -F
# Allow established connections
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allow SSH, VNC, Web etc
iptables -A INPUT -p tcp --dport ssh -j ACCEPT