Skip to content

Instantly share code, notes, and snippets.

View james2doyle's full-sized avatar

James Doyle james2doyle

View GitHub Profile
@james2doyle
james2doyle / json-in-sqlite.sql
Last active January 18, 2024 19:31
use SQLite to store JSON à la jsonb in PostgreSQL using virtual generated columns (https://www.sqlite.org/gencol.html)
CREATE TABLE t (
id integer PRIMARY KEY autoincrement,
data text
);
INSERT INTO my_objects (data) values('{"foo": "value", "bar": "other value"}'), ('{"foo": "baz", "bar": "qux"}');
ALTER TABLE my_objects ADD COLUMN foo text GENERATED always AS (json_extract(data, $.foo)) virtual;
SELECT * FROM my_objects;
@james2doyle
james2doyle / vue.sublime-project
Last active January 16, 2024 21:24
A Sublime project file for Vue projects
{
"folders": [
{
"file_exclude_patterns": [
".eslintcache",
".gitkeep",
"*.min.*",
"*.snap",
"*.pem",
"*lock*"
@james2doyle
james2doyle / nuxt.sublime-project
Last active January 16, 2024 21:23
A starting configuration file for Sublime Text Nuxt Vue projects
{
"folders": [
{
"file_exclude_patterns": [
".eslintcache",
".gitkeep",
"*.min.*",
"*.snap",
"*.pem",
"*lock*"
@james2doyle
james2doyle / it-is-easier-to-make-things-great-in-vue.md
Last active January 16, 2024 19:11
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 / atom-nice-font.less
Created February 27, 2014 22:12
nice fonts and scrollbars in the Atom editor!
body {
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
-moz-osx-font-smoothing: grayscale;
}
.tree-view-resizer, .editor {
::-webkit-scrollbar {
width: 0.5em;
height: 0.5em;
@james2doyle
james2doyle / httpie.mailgun.sh
Created December 17, 2015 21:03
Test the mailgun API with HTTPIE
#!/usr/bin/env bash
DOMAIN="example.com"
EMAIL="contact@personalemail.com"
http -a 'api:key-00000000000000000000000000000000' \
-f POST "https://api.mailgun.net/v3/$DOMAIN/messages" \
from="Excited User <postmaster@$DOMAIN>" \
to="$EMAIL" \
subject="Hello" \
@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 / feed.xml
Created August 27, 2015 15:14
Example of an RSS Atom feed. Has images, author, and expanded entries.
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Primer CMS</title>
<subtitle>Primer CMS is the new product from WARPAINT Media.</subtitle>
<link href="http://localhost:8888/warpaint-laravel-cms/public"></link>
<link href="http://localhost:8888/warpaint-laravel-cms/public/feed.xml" rel="self" />
<id>http://localhost:8888/warpaint-laravel-cms/public/</id>
<description>Primer CMS is the new product from WARPAINT Media.</description>
<updated>2015-08-27T15:10:58+00:00</updated>
<entry>
@james2doyle
james2doyle / scrollTo.js
Last active November 29, 2023 11:41
a native scrollTo function in javascript that uses requestAnimationFrame and easing for animation
// easing functions http://goo.gl/5HLl8
Math.easeInOutQuad = function (t, b, c, d) {
t /= d/2;
if (t < 1) {
return c/2*t*t + b
}
t--;
return -c/2 * (t*(t-2) - 1) + b;
};
@james2doyle
james2doyle / rules.txt
Last active November 21, 2023 17:39
Some ublock rules that block elements that match specific pieces of text
! 2022-03-24 https://twitter.com
twitter.*##div[aria-label="Timeline: Trending now"]
twitter.*##div[aria-label="Home timeline"] > div > div article:has(div > div > div > span:has-text(Ad))
! 2022-03-29 https://google.com
google.*##.g:has(a[href*="thetopsites.com"])
google.*##.g:has(*:has-text(/bye topic of noninterest/i))