Add the following line to your ApplicationController:
around_action AssetPreloadingBag::FilterAnd when you want to prerender something, you can simply call:
| type Validator<Input, Error> = (input: Input) => Error[]; | |
| type ExtractValidatorError<V extends Validator<any, any>> = V extends Validator<any, infer A> ? A : never; | |
| function error<Error>(error: Error): Error[] { | |
| return [error]; | |
| } | |
| function ok(): any[] { | |
| return []; | |
| } |
| function textNodesUnder(el){ | |
| var n, a=[], walk=document.createTreeWalker(el,NodeFilter.SHOW_TEXT,null,false); | |
| while(n=walk.nextNode()) a.push(n); | |
| return a; | |
| } | |
| for (let node of textNodesUnder(document.documentElement)) { | |
| node.nodeValue = node.nodeValue.replace(/[^\s]/g, '█'); | |
| } |
| type IndexableKeys<T> = { [key in keyof T]: T[key] extends string ? key : never }[keyof T]; | |
| function matcher<T>(): <K extends IndexableKeys<T>>(key: K) => <R>( | |
| legs: { | |
| [key in Extract<T[Extract<K, keyof T>], string>]: (arg: T & Record<K, key>) => R | |
| } | |
| ) => (t: T) => R { | |
| return (key) => (legs) => (t) => { | |
| const state = t[key]; | |
| return legs[state](t); |
| const puppeteer = require("puppeteer"); | |
| const { default: fetch } = require("node-fetch"); | |
| const path = require("path"); | |
| const fs = require("fs"); | |
| const FILES = path.join(__dirname, "shvetz"); | |
| async function main() { | |
| const browser = await puppeteer.launch(); | |
| const page = await browser.newPage(); |
| let lastFocusedId = null; | |
| document.addEventListener("turbolinks:request-start", function () { | |
| const element = document.querySelector( | |
| "[data-turbolinks-preserve-focus]:focus" | |
| ); | |
| if (element) { | |
| lastFocusedId = element.id; | |
| } |
| function* enumerate(xs) { | |
| let i = 0; | |
| for (const x of xs) { | |
| yield [i++, x]; | |
| } | |
| } | |
| function mregex(modifiers) { | |
| return (strings, ...args) => { | |
| let result = ""; |
| function SetUUID() { | |
| var spreadsheet = SpreadsheetApp.getActive(); | |
| const range = spreadsheet.getActiveRange() | |
| range.setValues(range.getValues().map(v => v.map(() => Utilities.getUuid()))); | |
| }; |
| // Available variables: | |
| // - Machine | |
| // - interpret | |
| // - assign | |
| // - send | |
| // - sendParent | |
| // - spawn | |
| // - raise | |
| // - actions |
| use std::collections::HashMap; | |
| trait Renderable: core::fmt::Debug { | |
| fn render(&self) -> String; | |
| } | |
| impl<A: Renderable, B: Renderable> Renderable for (A, B) { | |
| fn render(&self) -> String { | |
| format!("{}{}", self.0.render(), self.1.render()) |