Skip to content

Instantly share code, notes, and snippets.

@markashleybell
markashleybell / gist:1139238
Created August 11, 2011 09:20
Form Markup
<form id="demo2" action="" method="post">
<p class="mab-checkbutton-container">
<input type="checkbox" value="1" name="cb-1" id="cb-1" /> <label for="cb-1">Checkbox 1</label>
<input type="checkbox" value="1" checked="checked" name="cb-2" id="cb-2" /> <label for="cb-2">Checkbox 2</label>
<input type="checkbox" value="1" checked="checked" name="cb-3" id="cb-3" /> <label for="cb-3">Checkbox 3</label>
</p>
<p><input type="submit" value="Submit Form and Show Values" /></p>
</form>
@markashleybell
markashleybell / index.html
Created April 5, 2013 08:44
Queueing asynchronous functions in JavaScript so that each is executed after the previous function has completed; useful when lookup data or templates are required to be loaded before other code can be executed.
<!DOCTYPE html>
<html>
<head>
<title>Queueing Asynchronous Functions in JavaScript</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="queue.js"></script>
</head>
<body>
<p><input type="button" id="process-button" value="Process Queue" /></p>
<div id="output"></div>
@markashleybell
markashleybell / crypto-aes-gcm.js
Created April 15, 2019 05:24 — forked from chrisveness/crypto-aes-gcm.js
Uses the SubtleCrypto interface of the Web Cryptography API to encrypt and decrypt text using AES-GCM (AES Galois counter mode).
/**
* Encrypts plaintext using AES-GCM with supplied password, for decryption with aesGcmDecrypt().
* (c) Chris Veness MIT Licence
*
* @param {String} plaintext - Plaintext to be encrypted.
* @param {String} password - Password to use to encrypt plaintext.
* @returns {String} Encrypted ciphertext.
*
* @example
* const ciphertext = await aesGcmEncrypt('my secret text', 'pw');
@markashleybell
markashleybell / github-mirror.ps1
Created August 10, 2019 07:59
Local GitHub repository backups with Powershell
param(
[Parameter(Mandatory=$true)]
[string]$Username,
[Parameter(Mandatory=$true)]
[string]$GitHubAccessToken,
[Parameter(Mandatory=$true)]
[string]$BackupFolderPath
)
$initialWorkingPath = Convert-Path '.'
@markashleybell
markashleybell / dropbox-db-backup.ps1
Last active February 16, 2021 17:43
Rolling backup of one or more SQL Server databases to Dropbox.
param(
[Parameter(Mandatory=$true)]
[string[]]$DatabaseNames,
[Parameter(Mandatory=$true)]
[string]$AccessToken,
[Parameter(Mandatory=$true)]
[string]$BackupPath
)
function Upload-FileToDropbox {
import os
import sys
import requests
from git import Repo
from string import Template
# Get the command-line arguments
user_type = sys.argv[1]
user_id = sys.argv[2]
@markashleybell
markashleybell / README.md
Last active November 13, 2022 09:57
Mastodon metadata proxy using a Cloudflare Worker

Inspired by this article by Maarten Balliauw, this Cloudflare Worker code enables a proxy for Mastodon metadata under your own domain, with a memorable alias.

This allows people to search for you under your own @user@domain alias, finding your account on whichever server it currently resides on. This has a lot of advantages when it comes to discoverability!

If you move servers, you can update the mastodonHandle value to reflect that; searching for the alias will then direct people to your account on the new server.

Example: search @me@markb.uk on your Mastodon server and you should find my account—if the search isn't currently broken because it's too busy. 😉