Skip to content

Instantly share code, notes, and snippets.

View github-backup.sh
#!/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:
View github-backup.cmd
@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:
View GPG Cheat Sheet.md

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
View copy.js
const copy = str => {
const el = document.createElement("textarea");
el.value = str;
document.body.appendChild(el);
el.select();
document.execCommand("copy");
document.body.removeChild(el);
};
View renew-letsencrypt-certificates.sh
#!/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
#
View cfg-firewall.sh
#!/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
@andygock
andygock / cfg-firewall.sh
Created August 7, 2019 14:46
Basic iptables starter script that only allow incoming SSH and ping
View cfg-firewall.sh
#!/bin/bash
#
# basic iptables starter script that only allow incoming SSH and ping
#
# default actions
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
@andygock
andygock / pi.sh
Created January 13, 2019 13:18
Back up and restore Raspbery Pi microsd card
View pi.sh
#!/bin/bash
#
# Usage:
# ./pi.sh backup /dev/sdb
# ./pi.sh restore /dev/sdb
#
# Files created and used during backup and restore:
# mbr.img sfdisk.dump partition[12].parted
#
# For raspbian images, use minimum 8GB microsd card
@andygock
andygock / cypress-drag-and-drop-test.js
Last active June 29, 2021 12:25
Cypress.io testing multiple file drag and drop uploads
View cypress-drag-and-drop-test.js
// 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 }));
@andygock
andygock / javascriptreact.json.txt
Last active February 6, 2018 13:21
Visual Studio Code Snippets for Javascript React
View javascriptreact.json.txt
{
// Place your snippets for JavaScript React here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"Print to console": {
"prefix": "log",
"body": [
"console.log('$1');",