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 { z } from "zod"; | |
| type Route<Result, Params> = { | |
| __params: Params; | |
| path: (params: Params) => string; | |
| schema: z.Schema<Result>; | |
| }; | |
| type RoutesBase = Record<string, Route<any, any>>; | 
  
    
      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
    
  
  
    
  | type Rectangle = { | |
| kind: "rectangle"; | |
| width: number; | |
| height: number; | |
| }; | |
| type Circle = { | |
| kind: "circle"; | |
| radius: number; | |
| }; | 
  
    
      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 * as glob from "glob"; | |
| import * as path from "path"; | |
| import * as fse from "fs-extra"; | |
| import * as prettier from "prettier"; | |
| const PARAM_REG = /^\[(.+)\]$/; | |
| type PageObj = { [key: string]: PageObj }; | |
| type PathItem = { type: "param" | "static"; name: string }; | 
  
    
      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 Subscription() { | |
| const subs: Array<() => void> = []; | |
| return { | |
| subscribe(cb: () => void) { | |
| subs.push(cb); | |
| // return unsub | |
| return () => { | |
| const index = subs.indexOf(cb); | 
  
    
      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 randomSequenceOfUnique(intermediateOffset: number, seedBase = 1) { | |
| // from https://preshing.com/20121224/how-to-generate-a-sequence-of-unique-random-integers/ | |
| let index = permuteQPR(permuteQPR(seedBase) + 0x682f01); | |
| function permuteQPR(x: number) { | |
| const prime = 16777199; | |
| const halfPrime = 8388599; | |
| if (x >= prime) return x; // The 17 integers out of range are mapped to themselves. | |
| // squaring can cause exceeding 2^53 | 
  
    
      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
    
  
  
    
  | async function fetchAsObjectURL(url) { | |
| const response = await fetch(url); | |
| const blob = await response.blob(); | |
| return URL.createObjectURL(blob); | |
| } | |
| fetchAsObjectURL('https://jsonplaceholder.typicode.com/todos/1'); | 
  
    
      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 notNull<T>(val: T | null): T { | |
| if (val === null) { | |
| throw new Error(`Invariant: value should not be null`); | |
| } | |
| return val; | |
| } | |
| function notNil<T>(val: T | null | undefined): T { | |
| if (val === null || val === undefined) { | |
| throw new Error(`Invariant: value should not be null | undefined`); | 
  
    
      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 [start] = useState(Date.now()); | |
| const [, setRandomNum] = useState(0); | |
| const diff = Date.now() - start; | |
| useEffect(() => { | |
| const current = diff % 1000; | |
| const time = 1000 - current; | |
| const timer = setTimeout(() => { | |
| setRandomNum(Math.random()); | 
  
    
      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
    
  
  
    
  | # redirect non www | |
| <% | |
| if (s.publicDomain.match(/^(?!(www\.)).+$/)) { | |
| %> | |
| server { | |
| <% | |
| if (!s.forceSsl) { | |
| %> | |
| listen 80; | |
| <% | 
  
    
      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
    
  
  
    
  | type Bit = 0 | 1; | |
| type Byte = [Bit, Bit, Bit, Bit, Bit, Bit]; | |
| type Decimal = | |
| | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | |
| | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | |
| | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | |
| | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | |
| | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 
NewerOlder