Skip to content

Instantly share code, notes, and snippets.

View willsheppard's full-sized avatar

Will Sheppard willsheppard

View GitHub Profile
@willsheppard
willsheppard / pinboard-bookmarklet.js
Created January 17, 2024 16:15 — forked from jsit/pinboard-bookmarklet.js
Pinboard Bookmarklet -- Use text selection for description if available, otherwise use meta description, and include referrer in description if exists.
javascript: q = location.href;
q = q.replace(/[?&]utm_[^&]*/g, "");
q = q.replace(/[?&]mc_[^&]*/g, "");
q = q.replace(/[?&]src=[^&]*/g, "");
q = q.replace(/[?&]ref=[^&]*/g, "");
desc = "";
if (document.getElementsByName("description").length > 0) {
desc = document.getElementsByName("description")[0].getAttribute("content")
"\n\n"
} else if (document.getElementsByName("Description").length > 0) {
@willsheppard
willsheppard / sudoers_cheat_sheet.md
Last active October 9, 2023 08:18
Sudoers cheat sheet

Define text editor

$ sudo update-alternatives --config editor

Edit /etc/sudoers file

$ sudo visudo /etc/sudoers
@willsheppard
willsheppard / google-meet-helper.user.js
Last active October 4, 2023 10:20
Google Meet Helper: auto camera off, auto mute, and auto-join
// ==UserScript==
// @name Google Meet helper
// @namespace Violentmonkey Scripts
// @match https://meet.google.com/*
// @grant none
// @version 1.3.04
// @author Vanshaj Girotra, Will Sheppard
// @description auto camera off, auto-mute, and auto join -- in that order. Also switches account (defaults to primary)
// @run-at document-idle
// ==/UserScript==
@willsheppard
willsheppard / elasticsearch.pl
Created September 29, 2023 10:30
ElasticSearch example query
use strict;
use warnings;
use Data::Dumper::Concise;
use Search::Elasticsearch;
my $ekk = Search::Elasticsearch->new(
client => '7_0::Direct',
nodes => [ 'https://opensearch.example.com/', ],
send_get_body_as => 'POST',
@willsheppard
willsheppard / atlassian_redirect.user.js
Last active September 13, 2023 10:36
Atlassian Confluence wiki and Jira redirect
// ==UserScript==
// @name AtlassianRedirect
// @namespace atlassian.com
// @version 0.09
// @grant none
// @run-at document-end
// @match *://*.atlassian.com/*
// @match *://*.atlassian.net/*
// @author Ludo Tolhurst-Cleaver, Will Sheppard, Dan Banks
// ==/UserScript==
@willsheppard
willsheppard / test2_cheat_sheet.md
Last active September 20, 2023 11:28
Test2 cheat sheet for Perl
@willsheppard
willsheppard / ms_ssi.js
Created May 26, 2023 08:53 — forked from emlyn/ms_ssi.js
I keep getting shown the "Stay signed in" page on Microsoft domains, even when I select "don't show this again" - this script will automatically click on "yes" for you every time the page comes up.
// ==UserScript==
// @name Stay signed in to MS
// @description Automatically click "yes" on the Microsoft "stay signed in" page that keeps appearing.
// @downloadURL https://gist.github.com/emlyn/2f0c9702bd83fe7d232ed58626c90ac7/raw/ms_ssi.js
// @updateURL https://gist.github.com/emlyn/2f0c9702bd83fe7d232ed58626c90ac7/raw/ms_ssi.js
// @namespace https://gist.github.com/emlyn/
// @version 0.2
// @author Emlyn Corrin
// @match https://login.microsoftonline.com/login.srf
// @icon https://c.s-microsoft.com/favicon.ico?v2
@willsheppard
willsheppard / sqlite.md
Created April 5, 2023 16:00
SQLite basics

Command line example:

$ sqlite3 -line -cmd 'select * from zip limit 1' database.sqdb < `which echo` ".exit"> output
@willsheppard
willsheppard / jq_cheat_sheet.md
Last active November 9, 2023 20:05
jq cheat sheet
@willsheppard
willsheppard / knex.js
Created July 13, 2022 13:49
Knex basics
knex.select()
.from('some_table')
.where({
name: 'Mr Foo'
})
.then((result) => {
// This block is *REQUIRED* or the query is not sent to the database!
if (! result[0]) {
console.log(`Error: "Mr Foo" was not found.`);
process.exit(1); // It is alright to exit here *IF* it's a fatal condition