Skip to content

Instantly share code, notes, and snippets.

Avatar

James Doyle james2doyle

View GitHub Profile
@james2doyle
james2doyle / hyperactiv-use-state-usage.js
Last active Nov 26, 2020
Use hyperactiv to recreate hooks with Javascript Proxy objects. Supports Redux devtool
View hyperactiv-use-state-usage.js
import setState from 'use-state.js';
const [state, onStateUpdated] = useState({ count: 1 });
console.log(state.count); // logs: "1"
// runs on init in order to compute dependencies
onStateUpdated(() => {
console.log('stateUpdated', state.count); // logs: "stateUpdated 1"
});
@james2doyle
james2doyle / json-lite-chrome-extension
Created Nov 7, 2020
JSON Lite Fast JSON viewer chrome extension theme that is close to the Adaptive.sublime-theme
View json-lite-chrome-extension
# https://chrome.google.com/webstore/detail/json-lite/acacmjcicejlmjcheoklfdchempahoag
font: 14px JetBrains Mono,monospace
text color: #fff;line-height:1.2
background color: #272E36
info color: #5B5B5B
info hover color: #fff;text-shadow: 1px 1px 3px rgba(255,255,255,0.4)
string color: #83B97D
number color: #F69E3F
boolean color: #E74551
null color: #E74551
@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
]]--
You can’t perform that action at this time.