Skip to content

Instantly share code, notes, and snippets.

View andygock's full-sized avatar

Andy Gock andygock

View GitHub Profile
@andygock
andygock / sync-to-external.cmd
Created April 14, 2017 08:09
Script to sync one directory to another using robocopy (suitable as a form of backup)
@echo off
setlocal
:: set target and source directory, do not use a trailing slash
:: recommended: sync to a subdir on target drive
set source_drive=z:
set target_drive=p:\drive_z
:: exclude these dirs from sync
set excluded_dirs=exclude1 exclude2 "exclude 3"
@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

@andygock
andygock / Windows 10 Tips.md
Last active November 26, 2023 11:28
Windows 10, remove bloatware and fix privacy issues. My personal notes for fresh installing Windows 10.
#!/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
#
@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:
#!/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:
::
:: Windows batch script to clear Firefox history.
::
:: Requires:
::
:: SDelete - https://technet.microsoft.com/en-us/sysinternals/sdelete.aspx
:: If you do not have SDelete, replace instances of 'sdelete' in this script with 'del'
::
:: sqlite3 - https://www.sqlite.org/download.html
::
@andygock
andygock / cypress-drag-and-drop-test.js
Last active June 29, 2021 12:25
Cypress.io testing multiple file drag and drop uploads
// drag and drop multiple files
Cypress.Commands.add("upload_files", (selector, fileUrlArray, type = "") => {
const files = [];
fileUrlArray.forEach((fileUrl) => {
cy.fixture(fileUrl, "base64")
.then(Cypress.Blob.base64StringToBlob)
.then((blob) => {
const nameSegments = fileUrl.split("/");
const name = nameSegments[nameSegments.length - 1];
files.push(new File([blob], name, { type }));

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);
};