Skip to content

Instantly share code, notes, and snippets.

View johnsonjo4531's full-sized avatar
🙂
👍🏻

John Johnson johnsonjo4531

🙂
👍🏻
View GitHub Profile
@johnsonjo4531
johnsonjo4531 / example-usage.ts
Last active June 2, 2022 20:04
Pingpong coroutine like library
import { pingpong } from "./pingpong";
const sleep = (ms: number) => new Promise((res) => setTimeout(res, ms));
(async () => {
const controller = pingpong<number, { done: true } | number>(async function ({
receive,
send
}) {
let num = 0;
@johnsonjo4531
johnsonjo4531 / machine.js
Last active November 25, 2020 19:58
Generated by XState Viz: https://xstate.js.org/viz
function canTraverse (graph, start, end) {
return Boolean(graph[start]?.[end]);
}
const questionsMachine = Machine({
id: "questions",
parallel: true,
context: {
routes: {
home: {
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@johnsonjo4531
johnsonjo4531 / machine.js
Last active July 21, 2020 00:45
Generated by XState Viz: https://xstate.js.org/viz
const auth = {
initial: 'started',
id: 'auth',
states: {
started: {
initial: 'signingOut',
states: {
signingOut: {
invoke: {
src: 'doSignOut',
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@johnsonjo4531
johnsonjo4531 / import-map.json
Last active December 28, 2019 21:50
Attempting to run Vectorious in Deno.
{
"imports": {
"https://raw.githubusercontent.com/mateogianolio/vectorious/master/src/core": "https://raw.githubusercontent.com/mateogianolio/vectorious/master/src/core/index.ts",
"https://raw.githubusercontent.com/mateogianolio/vectorious/master/src/core/copy": "https://raw.githubusercontent.com/mateogianolio/vectorious/master/src/core/copy.ts",
"https://raw.githubusercontent.com/mateogianolio/vectorious/master/src/core/combine": "https://raw.githubusercontent.com/mateogianolio/vectorious/master/src/core/combine.ts",
"https://raw.githubusercontent.com/mateogianolio/vectorious/master/src/core/array": "https://raw.githubusercontent.com/mateogianolio/vectorious/master/src/core/array.ts",
"https://raw.githubusercontent.com/mateogianolio/vectorious/master/src/core/angle": "https://raw.githubusercontent.com/mateogianolio/vectorious/master/src/core/angle.ts",
"https://raw.githubusercontent.com/mateogianolio/vectorious/master/src/core/slice": "https://raw.githubusercontent.com/mateogianolio
@johnsonjo4531
johnsonjo4531 / LICENSE
Last active December 21, 2019 21:30
Some GTOR functions
The MIT License (MIT)
Copyright (c) 2014 Kris Kowal, johnsonjo4531
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@johnsonjo4531
johnsonjo4531 / .dockerignore
Last active September 12, 2019 01:03
An example of a failed pkg run
node_modules
index*
!index.js
@johnsonjo4531
johnsonjo4531 / LICENSE
Last active September 11, 2019 02:49
Prefix and givenfiles in a certain directory
Copyright 2019 johnsonjo4531
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHE
@johnsonjo4531
johnsonjo4531 / index.html
Last active September 4, 2019 02:56
Principles of e-commerce: Modern JavaScript Crash-Course
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Hello</title>
</head>
<body>
<h1>Hello HTML!</h1>