Skip to content

Instantly share code, notes, and snippets.

View ashtonmeuser's full-sized avatar

Ashton Meuser ashtonmeuser

  • Dialpad
  • Vancouver, BC
View GitHub Profile
//bookmarklet-title: Canvas DL
//bookmarklet-about: When playing skribbl.io and someone has made a nice drawing, this lets you download the current drawing as a PNG.
var w = window.wdq || (window.wdq = document.createElement("a"));
var p = /The word was '([^']*)'/g,
pp = /<span>([^<>]+) is drawing now!/g,
tt = document.body.innerHTML;
var mm, nn, xx;
while (mm = p.exec(tt)) nn = mm;
while (mm = pp.exec(tt)) xx = mm;
@ashtonmeuser
ashtonmeuser / outline.js
Last active January 14, 2022 09:31
Outline article
//bookmarklet_title: Outline
javascript:(function(){window.location = 'https://outline.com/' + window.location})()
@ashtonmeuser
ashtonmeuser / unhide.js
Created June 1, 2021 03:51
Bookmarklet that toggles hidden elements
// bookmarklet-title: Unhide
// bookmarklet-about: Toggle hidden elements. Credit to u/jcunews1 via https://www.reddit.com/r/bookmarklets/comments/nowz0j/toggle_hidden_elements
if (window.unhiddens_bmkl) {
unhiddens_bmkl.forEach(o => o[0].style.cssText = o[1]);
unhiddens_bmkl = undefined;
} else {
window.unhiddens_bmkl = [];
document.body.querySelectorAll('*:not(script,style)').forEach(e => {
if (getComputedStyle(e).display === 'none') {
@ashtonmeuser
ashtonmeuser / hasher.go
Created April 13, 2021 06:15
Calculate hash as an io.Reader is read
package hasher
import (
"crypto/sha1"
"encoding/hex"
"hash"
"io"
)
// HasherReader calculates the hash of a byte stream
@ashtonmeuser
ashtonmeuser / launch.js
Created April 11, 2021 17:11
Simple Node debugging configuration for VSC
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
// bookmarklet-title: Eno
// bookmarklet-about: Plays demoscene interpretation of Brian Eno's 1/2 from the album Ambient 1. Original code by Mathieu Henri (http://www.p01.org/music_for_tiny_airports).
const k = 8192;
let t = 0;
const AudioContext = window.AudioContext || window.webkitAudioContext;
const ac = new AudioContext();
const sp = ac.createScriptProcessor(k, 0, 1);
sp.connect(ac.destination);
sp.onaudioprocess = pe => {
export default (src) => new Promise((resolve, reject) => {
const script = document.createElement('script');
script.src = src;
script.onload = resolve;
script.onerror = reject;
document.head.appendChild(script);
});
//bookmarklet_title: Word Frequency
//bookmarklet_about: Display the top five most common words on a webpage. Drag the bookmarklet to your bookmarks bar to use it anywhere! If the word hippo shows up a lot, hippo should have a high occurrence (hippo hippo HIPPO).
var counts = { };
var text = document.body.innerText || document.body.textContent || '';
var words = text.split(/\b/).filter((word) => {
return word.match(/^\w+$/) !== null;
});
words.forEach((word) => {
# Prompt
PROMPT='%{%F{red}%}♥%{%F{default}%} %1~ %# '
# Aliases
alias gitlg="git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all"
# Misc.
export GREP_OPTIONS='--color=auto'
class Modal {
constructor(message, timeout=3000) {
this.fadeTime = 500;
this.modalBackground = '#f00';
this.present(message);
this.removeTimer = setTimeout(this.remove.bind(this), timeout);
this.fadeTimer = setTimeout(this.fade.bind(this), timeout - this.fadeTime);
}
present(message) {