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
type PropName = string; | |
type DateName = string; | |
export type PropDataNames = [PropName, DateName]; | |
export function syncState(...tuples: PropDataNames[]) { | |
const watcher = {} as { [index: string]: (v: any) => void }; | |
for (const tuple of tuples) { | |
const [propName, dataName] = tuple; |
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
#[derive(PartialEq, Eq, Clone, Debug)] | |
pub struct ListNode { | |
pub val: i32, | |
pub next: Option<Box<ListNode>>, | |
} | |
impl ListNode { | |
#[inline] | |
fn new(val: i32) -> Self { | |
ListNode { next: None, val } |
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 { useEffect, useRef } from "react"; | |
import { ResizeSensor, ResizeSensorCallback } from "css-element-queries"; | |
function newResizeSensor( | |
targetNode: HTMLElement | null, | |
callback: ResizeSensorCallback, | |
) { | |
return targetNode ? new ResizeSensor(targetNode, callback) : null; | |
} |
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 React from "react"; | |
import { withThemeContext } from "./context"; | |
const MyComponent = withThemeContext( | |
class extends React.Component { | |
constructor() { | |
super(); | |
this.handleToggleTheme = this.handleToggleTheme.bind(this); | |
} |
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
function csprng() { | |
const maxU32 = 0xFFFFFFFF; | |
return crypto.getRandomValues(new Uint32Array(1))[0] / maxU32; | |
} |
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
async function sha2(txt, sha = "SHA-256") { | |
const encoder = new TextEncoder(); | |
const message = encoder.encode(txt); | |
const digest = await crypto.subtle.digest(sha, message); | |
return Array.from(new Uint8Array(digest)).map((x) => x.toString(16).padStart(2, "0")).join(""); | |
} |
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
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Calculate SHA-2 of a file</title> | |
</head> | |
<body> | |
<input type="file" id="file-input" onchange="handleFileChange(event)" /> | |
<select id="sha2-algo-select" onchange="handleSelectChange(event)"> |
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 "~antd/dist/antd.css"; | |
.App { | |
padding: 50px; | |
} | |
.App button { | |
margin: 10px; | |
} |
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 "~antd/dist/antd.css"; | |
.App { | |
padding: 50px; | |
} | |
.App button { | |
margin: 10px; | |
} |
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 { Observable, Subscriber, fromEvent } from "rxjs"; | |
import { ajax } from "rxjs/ajax"; | |
import { | |
pluck, | |
debounceTime, | |
filter, | |
tap, | |
map, | |
switchMap, | |
defaultIfEmpty, |