Skip to content

Instantly share code, notes, and snippets.

Avatar

James Doyle james2doyle

View GitHub Profile
@james2doyle
james2doyle / content-markdown-cheatsheet.md
Created Oct 23, 2020
Markdown cheatsheet that is more oriented towards content. Stolen from https://rsms.me/markdown-wasm/
View content-markdown-cheatsheet.md

Example

A third of the distance across the Beach, the meadow ends and sand begins. This slopes gradually up for another third of the distance, to the foot of the sand hills, which seem tumbled into their places by some mighty power, sometimes three tiers of them deep, sometimes two, and sometimes only one. A third of the distance across the Beach, the meadow ends and sand begins.

The outline of this inner shore is most irregular, curving and bending in and out and back upon itself, making coves and points and creeks and channels, and often pushing out in flats with not water enough on them at low tide to wet your ankles.

Subtitle

This is another fine paragraph

@james2doyle
james2doyle / body.css
Last active Nov 16, 2020
Sane defaults for the body tag in CSS
View body.css
body {
margin: 0;
padding: 0;
min-width: 100vw;
min-height: 100vh;
font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
font-feature-settings: 'lnum' 1;
font-variant-numeric: lining-nums;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
@james2doyle
james2doyle / OPTIONS.mock
Created Oct 6, 2020
Mocks for mockserver for fetch requests. Run with: mockserver -p 5555 -m './'
View OPTIONS.mock
HTTP/1.1 204 No Content
Allow: OPTIONS, GET, HEAD, POST
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: OPTIONS, GET, HEAD, POST
Access-Control-Allow-Headers: Authorization,content-type
Access-Control-Allow-Credentials: true
Content-Length: 0
Content-Type: text/plain
@james2doyle
james2doyle / event-logger.ts
Created Oct 6, 2020
Nuxt plugin for the Winston logger. Includes setup for logging in the browser console. Written in TypeScript
View event-logger.ts
import { Plugin } from '@nuxt/types';
import logger from 'logger';
const eventLogger: Plugin = (context, inject) => {
// Inject $logger in Vue, context and store.
inject('logger', logger);
// For Nuxt <= 2.12, also add 👇
context.$logger = logger;
};
@james2doyle
james2doyle / emitter.ts
Created Oct 6, 2020
Nuxt plugin for the mitt event emitter. Written in TypeScript
View emitter.ts
import * as mitt from 'mitt';
const emitter: mitt.Emitter = mitt.default();
// log all events in development
if (process.env.NODE_ENV === 'development') {
emitter.on('*', console.info.bind(console));
}
export default emitter;
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@james2doyle
james2doyle / gist:53f4316d5f885b6f51119e086b660d99
Created Sep 14, 2020
Hammerspoon script to easily find the emails of the people I work with
View gist:53f4316d5f885b6f51119e086b660d99
--[[
Name: Emails
Author: James Doyle <james2doyle@gmail.com>
Description: Easily find the emails of the people I work with
Demo: <None>
Installation: Just require this file in your Hammerspoon init.lua file
Usage:
Press the keybinding (ctrl+shift+E) and filter the results
Selecting one copies it to your clipboard
]]--
@james2doyle
james2doyle / nuxt-i18n-programmatic-2.ts
Last active Nov 6, 2020
Call the $t method on the shared Vue instance programmatically in Nuxt
View nuxt-i18n-programmatic-2.ts
// later versions of Nuxt have errors with original code
import VueI18n from 'vue-i18n';
/**
* Translate a string
*
* @param {string} key
*
* @returns {string}
*/
@james2doyle
james2doyle / tailwindcss.d.ts
Last active Sep 9, 2020
TailwindCSS Typescript definitions file for v1.7.0
View tailwindcss.d.ts
/**
** TailwindCSS Typescript definitions File
** v1.7.0
**
** Docs: https://tailwindcss.com/docs/configuration
** Default: https://github.com/tailwindcss/tailwindcss/blob/master/stubs/defaultConfig.stub.js
Usage in `tailwind.config.js`:
// @type {import('tailwindcss/types').Theme}
const defaultTheme = require('tailwindcss/defaultTheme');