Create an observable emitting each item passed in.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const S1Time = Symbol('S1Time'); | |
function DriverTime() { | |
function* NoTime() { | |
yield on('sector1Set', SectorTime, id('Sector1')); | |
yield on('sector2Set', SectorTime, id('Sector2')); | |
yield on('sector3Set', SectorTime, id('Sector3')); | |
} | |
function* SectorTime() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function* VideoID() { | |
const [videoID] = yield /^[a-zA-Z0-9_]+$/; | |
return videoID; | |
} | |
function* Long() { | |
yield "https://www.youtube.com/watch?v="; | |
const videoID = yield VideoID; | |
return videoID; | |
} | |
function* Embed() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function* TrafficLights() { | |
function* Green() { | |
yield on("timer", Yellow); | |
} | |
function* Yellow() { | |
yield on("timer", Red); | |
} | |
function* Red() { | |
yield on("timer", Green); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function Loader() { | |
function* Loading() { | |
yield on("error", Failed); | |
yield on("timeout", TimedOut); | |
yield on("abort", Aborted); | |
yield on("success", Loaded); | |
} | |
function* Failed() {} | |
function* TimedOut() {} | |
function* Aborted() {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function loader($request) { | |
return getProjects(); | |
} | |
function action($request) { | |
$form = $request.formData(); | |
return createProject([ "title" => $form.get("title") ]); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Pi to 8 decimal places | |
*/ | |
export const pi = 3.14159265; | |
export const dateFormat = "YYYY/MM/DD"; | |
export const isEnabled = true; | |
export const flavors = ["vanilla", "chocolate", "caramel", "raspberry"]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { DispatchWithoutAction, useEffect, useMemo, useReducer } from 'react'; | |
import type { DependencyList, EffectCallback } from 'react'; | |
/** | |
* A logical clock. | |
* | |
* @returns a tuple with the current clock value, and a stable function that advances the clock. | |
*/ | |
export function useTicker(): [number, DispatchWithoutAction] { | |
return useReducer(n => n + 1, 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See: https://twitter.com/buildsghost/status/1436394640861646848 | |
envars | |
|> Object.keys(in) | |
|> in.map(envar => `${envar}=${envars[envar]}`) | |
|> in.join(' ') | |
|> `$ ${in}` | |
|> chalk.dim(in, 'node', args.join(' ')) | |
|> console.log(in) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Runs using the open source Mac app https://www.hammerspoon.org | |
-- Install Hammerspoon, and then copy this Gist into a file at ~/.hammerspoon/init.lua | |
require("hs.ipc") | |
hs.ipc.cliInstall() | |
local math = require("hs.math") | |
currentSpeech = nil |