Skip to content

Instantly share code, notes, and snippets.

View james2doyle's full-sized avatar

James Doyle james2doyle

View GitHub Profile
@james2doyle
james2doyle / split-file-and-run-command.sh
Created January 19, 2024 17:37
Split a file into lines and run a command for each one. This example is run on cURL
awk '{printf("%s\0", $1)}' list.txt | xargs -0 -n 1 curl -I
@james2doyle
james2doyle / it-is-easier-to-make-things-great-in-vue.md
Last active June 10, 2024 02:37
A comparison between using Nuxt/Vue and Next/React

It is easier to make things great in Vue

TLDR: It is easier to make things great in Vue because it helps you and requires less magic and complexity.

I’ve been playing with the latest version of Nuxt over the last few weekends.

I’ve been using a recent Next (v13) site as the base for a project. I have the basic top level routes recreated now.

So I have touched all the major parts. These are my thoughts on the reasons I think Vue is better than React for content driven sites.

@james2doyle
james2doyle / simple-reactive-vue-state.js
Last active December 13, 2023 17:19
The simplest solution to lots of state management problems is to use a composable to create a shareable data store. This pattern has a few parts: 1. A global state singleton 2. Exporting some or all of this state 3. Methods to access and modify the state
/*
* The simplest solution to lots of state management problems is to use a composable to create a shareable data store.
*
* This pattern has a few parts:
*
* A global state singleton
* Exporting some or all of this state
* Methods to access and modify the state
*/
import { reactive, toRefs, readonly } from 'vue';
@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 May 29, 2024 20:44
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;
}