import { createContext, useContext, useState, useMemo } from 'react';
export const createStore = (state, actions) => {
const set = (obj) =>
obj && typeof obj === 'object'
? ((state = { ...state, ...obj }), state)
: state;
const newActions = Object.keys(actions)
const loadMode = (editor, filename: string) => {
if (!editor) return;
const CodeMirror = window.CodeMirror;
// @ts-ignore
window.CodeMirror.modeURL = scriptCfg.baseUrl + "mode/%N/%N.min.js";
var val = filename,
m: any[],
mode: string,
spec: string | CodeMirror.ModeSpec<CodeMirror.ModeSpecOptions>;
import { Application, Router } from "https://deno.land/x/oak@v10.4.0/mod.ts";
const app = new Application();
const router = new Router();
// routes
router.get("/", ({ response }: { response: Response }) => {
const data = `<h3>Hello Deno</h3>`;
response.headers.set("content-type", "text/html");
const ucFirst = (str: string) =>
str
.split("")
.map((v, i) => (i === 0 ? v.toUpperCase() : v))
.join("");
const lcFirst = (str: string) =>
str
.split("")
.map((v, i) => (i === 0 ? v.toLowerCase() : v))
This file contains 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
@Composable | |
fun TestPrefs() { | |
val (count, isLoading, setCount) = rememberIntPreferences("counter", 0) | |
Column { | |
Text("Current Count: ${if (isLoading) "loading" else count}") | |
Button(onClick = { setCount(count+1) }) { | |
Text("Increment by 1") | |
} | |
Button(onClick = { setCount(count-1) }) { |
// file: react_test.ts
// it just for my note
import React from "https://esm.sh/react@18.2.0";
import ReactDomServer from "https://esm.sh/react-dom@18.2.0/server";
import { Handler, serve } from "https://deno.land/std@0.161.0/http/server.ts";
const Module = {
default: () =>
React.createElement("div", {
This file contains 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 type TRouter<Value, Method extends string> = | |
& { | |
find: (method: Method, pathname: string) => TMatchedRoute<Value>; | |
} | |
& { | |
[k in Lowercase<Method>]: ( | |
pathname: string, | |
...values: Value[] | |
) => TRouter<Value, Method>; | |
}; |
This file contains 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
interface ICtx { | |
readonly req: Request; | |
readonly params: Record<string, any>; | |
readonly env: Record<string, any>; | |
readonly executionContext: Record<string, any>; | |
} | |
type TExecResult = { | |
groups: Record<string, string>; | |
}; | |
type THandler = ( |
This file contains 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 { hash } from "https://deno.land/x/bcrypt@v0.4.1/mod.ts"; | |
import { Kysely } from "https://esm.sh/kysely@0.22.0"; | |
export async function seed(db: Kysely<unknown>) { | |
const userAdmin = await db.selectFrom("users" as never).where( | |
"email", | |
"=", | |
"admin@example.net" as never, | |
).executeTakeFirst(); | |
if (!userAdmin) { |
This file contains 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 "https://deno.land/std@0.170.0/dotenv/load.ts"; | |
import { parse } from "https://deno.land/std@0.170.0/flags/mod.ts"; | |
import { serve, Status } from "https://deno.land/std@0.170.0/http/mod.ts"; | |
import { Pool, PoolClient } from "https://deno.land/x/postgres@v0.17.0/mod.ts"; | |
const args = parse(Deno.args, { | |
string: ["dsn", "port", "key"], | |
alias: { "d": "dsn", "p": "port", "k": "key" }, | |
default: { | |
dsn: Deno.env.get("PG_DSN"), |
OlderNewer