Skip to content

Instantly share code, notes, and snippets.

View james2doyle's full-sized avatar

James Doyle james2doyle

View GitHub Profile
@james2doyle
james2doyle / tsconfig.json
Created October 16, 2023 17:39
A tsconfig file that works with Volar/Vue Language Tools on Vue 2.x projects
{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"sourceMap": true,
"allowJs": true
},
@james2doyle
james2doyle / typescript.sublime-project
Last active October 6, 2023 20:39
A sublime project file for Typescript code
{
"folders": [
{
"file_exclude_patterns": [
".gitkeep",
"*.min.*",
"*.ts.snap",
"*lock*"
],
"folder_exclude_patterns": [
@james2doyle
james2doyle / search-on-kagi.sh
Created May 17, 2023 22:19
A simple Raycast script for passing your query to the Kagi FastGPT bot
#!/bin/bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Search on Kagi
# @raycast.mode compact
# @raycast.argument1 { "type": "text", "placeholder": "query", "percentEncoded": true }
# Optional parameters:
# @raycast.icon images/icon-kagi.png
@james2doyle
james2doyle / Linkoln.py
Created April 17, 2023 19:54
Linkoln parses wikilinks out of a markdown document, and searches the world wide web to find a hyperlink for each one. https://animaomnium.github.io/keep-stuff-linkable/
#!/usr/bin/python3
# Linkoln by Anima Omnium
# Dedicated to the Public Domain
# https://animaomnium.github.io/keep-stuff-linkable/
# [[programming language:Rust]] is a [[systems programming language]] bootstrapped from [[rust prehistory|OCaml]].
# [Rust][1] is a [systems programming language][2] bootstrapped from [OCaml][3].
# [1]: https://www.rust-lang.org
# [2]: https://en.wikipedia.org/wiki/System_programming_language
# [3]: https://github.com/graydon/rust-prehistory
@james2doyle
james2doyle / bookmark.js
Created April 17, 2023 17:38
A bookmarklet to open the current Mastodon page in Elk.zone
// Save this as the URL for your bookmark and click the bookmark when you are on the page you want to open in Elk
javascript:void function(){window.location=`https://elk.zone/${window.location.hostname}${window.location.pathname}`}();
@james2doyle
james2doyle / stateful-switch-custom-element.demo.css
Created April 12, 2023 23:17
An example of a custom element that can toggle a state which can be used to control the elements. Demo: https://stackblitz.com/edit/stateful-switch-custom-element or https://stateful-switch-custom-element.stackblitz.io/
stateful-switch > *:not([switch-active]) {
display: none;
}
/* Demo: https://js-toggle-custom-element.stackblitz.io/ */
[is='toggle-container'] > *:not([is='toggle-button']) {
display: none;
}
[is='toggle-container'][open] > *:not([is='toggle-button']) {
display: block;
}
@james2doyle
james2doyle / Canary Ortho.tfl
Last active March 31, 2023 19:54
Keyboard layouts for Apsu Canary and Wreathy that work on Type Fu https://type-fu.com/app
{
"id": "custom-cc37d55a-4b1f-4a3c-9f49-6f3e0cd15520",
"name": "Canary (Ortho)",
"description": "https://github.com/Apsu/Canary#ortho",
"version": 1,
"keys": {
"Digit1": {
"default": {
"base": "1",
"shift": "!"
@james2doyle
james2doyle / postgresql-encrypt-decrypt.sql
Last active May 13, 2023 19:00
A Postgresql trigger and function to encrypt and decrypt a field
CREATE OR REPLACE FUNCTION encrypt_field()
RETURNS TRIGGER
AS $func$
BEGIN
IF PGP_SYM_ENCRYPT(NEW.encrypted_field, 'the-password-here')::text != OLD.encrypted_field::text THEN
NEW.encrypted_field := PGP_SYM_ENCRYPT(NEW.encrypted_field, 'the-password-here')::text;
END IF;
RETURN NEW;
END
$func$
<?php
$mappings = [
82 => [
'key' => 'R',
'message' => 'Redownloading all pages...',
],
114 => [
'key' => 'r',
'message' => 'Redownloading all pages...',