Skip to content

Instantly share code, notes, and snippets.

View jimthedev's full-sized avatar

Jim Cummins jimthedev

View GitHub Profile
@jimthedev
jimthedev / pizza.md
Last active January 19, 2022 16:53

Neopolitan Pizza at Home (using a pan)

The general idea behind this recipe is to:

  1. Make a delicious dough, using some sugar to help brown in home oven
  2. Rest / rise the dough at 66-72F
  3. Portion out the dough (freeze some of them if desired)
  4. Fashion a pizza from a dough portion
  5. Put ingredients on pizza
  6. Put a little drizzle of evoo on the top
@jimthedev
jimthedev / gist:70ff81a2d3ab1e74b953ea7b83b747d9
Created April 13, 2020 17:59
onKeyCombo directive angular.js angular1
const angular = require('angular');
function OnKeyComboDirective () {
return function (scope, element, attributes) {
// We're using a custom event listener on keyup
const comboListener = e => {
if ((e.ctrlKey || e.metaKey) && e.shiftKey && e.which == 65) {
setTimeout(function () {
scope.$eval(attributes.onKeycombo);
@jimthedev
jimthedev / load-latest-react.js
Last active February 6, 2020 16:39
load-latest-react
// Make sure you have an html element with an id of root and thewn you can run this. r is react, d is react-dom
Promise.all([
import(
"https://cdn.jsdelivr.net/npm/@esm-bundle/react-dom/esm/react-dom.resolved.production.min.js"
),
import(
"https://cdn.jsdelivr.net/npm/@esm-bundle/react/esm/react.production.min.js"
)
]).then(([{ default: d }, { default: r }]) =>
@jimthedev
jimthedev / gist:74d451f71975b504f0a223850481c9c2
Last active January 21, 2020 20:29
React StoreProvider, useStore hook
const context = React.createContext()
export const StoreProvider = ({ children, initialState = {} }) => {
const [store, setStore] = React.useState(() => initialState)
const contextValue = React.useMemo(() => [store, setStore], [store])
return (
<context.Provider value={contextValue}>
{children}
@jimthedev
jimthedev / React-Table-Plugin-Rules.md
Created January 21, 2020 20:20
the rules of react table's plugin system

They are reducers. Unlike other places, don't return existing state. Return undefined, unless something actually changed. Any action can be handled by all other plugins. No way for one plugin to block another.

@jimthedev
jimthedev / statemachine.js
Created January 21, 2020 20:16
state machine using reducer
const reducer = (state, action) => {
if (state.status === 'idle') {
if (action.type === 'fetch') {
return {
status: 'fetching'
}
}
}
if (state.status === 'fetching') {
if (action.type === 'resolve') {
@jimthedev
jimthedev / call.js
Last active January 11, 2020 02:37
faunadb incrementbyid function
Call(Function("increment"), "topics", "254119747652682260", [
"data",
"clickCount"
]);
/*
each document in the topics collection looks like this:
@jimthedev
jimthedev / Component.js
Last active July 23, 2020 11:49
use web component hook for react
import { useCustomElement } from "./useCustomElement";
// My regular react app that is using a web component /
// custom element inside it.
// Notice that we have some handlers, some state, etc.
function Component() {
const [txt, setTxt] = React.useState("init")
function handleClick() {
setTxt("clicked")
}
@jimthedev
jimthedev / myfile.html
Created July 17, 2018 20:50
myfile.html
<h1>Yo</h1>
@jimthedev
jimthedev / index.js
Last active July 2, 2018 14:54
precalculate.tree
const expect = require("expect");
const nav = {
children: [
{
text: "Home",
link: "/home",
children: [
{
text: "About",