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
class CustomStorage { | |
// eslint-disable-next-line no-use-before-define | |
public static instance: CustomStorage | null = null | |
public myStorage: Map<string, { val: any; exp: number }> = new Map() | |
constructor({ clearExpire = true }) { | |
for (const [k, p] of Object.entries(localStorage)) { | |
if (/_isMystorage/.test(p)) | |
try { |
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
use core::fmt; | |
struct Node { | |
val: i32, | |
next: Option<Box<Node>>, | |
} | |
impl Node { | |
fn new(val: i32) -> Self { | |
Self { val, next: None } |
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
const { Socket } = require('net') | |
class MineStatus { | |
/** @type {Socket} */ | |
socket | |
/** @type {string} */ | |
host | |
/** @type {number} */ |
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
pub enum HttpStatus { | |
CONTINUE = 100, | |
SWITCHING_PROTOCOLS = 101, | |
PROCESSING = 102, | |
EARLYHINTS = 103, | |
OK = 200, | |
CREATED = 201, | |
ACCEPTED = 202, | |
NON_AUTHORITATIVE_INFORMATION = 203, | |
NO_CONTENT = 204, |
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 async1() { | |
console.log('async1 start') | |
new Promise((resolve, reject) => { | |
try { | |
throw new Error('error1') | |
} catch (e) { | |
console.log(e) | |
} | |
setTimeout(() => { | |
resolve('promise4') |
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
{ | |
"workbench.colorTheme": "One Dark Pro Darker", | |
"workbench.preferredDarkColorTheme": "Vitesse Dark", | |
"workbench.preferredLightColorTheme": "Vitesse Light", | |
"workbench.iconTheme": "material-icon-theme", | |
"workbench.editor.closeOnFileDelete": true, | |
"workbench.editor.limit.enabled": true, | |
"workbench.editor.limit.perEditorGroup": true, | |
"workbench.editor.limit.value": 5, | |
"workbench.list.smoothScrolling": true, |
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
use std::cell::RefCell; | |
use std::cmp; | |
use std::collections::HashSet; | |
use std::fmt::Debug; | |
use std::hash::Hash; | |
use std::rc::Rc; | |
#[derive(Debug)] | |
#[allow(dead_code)] | |
struct CalcResult<'a> { |
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
use std::collections::HashMap; | |
struct Solution; | |
impl Solution { | |
pub fn int_to_roman(int: i32) -> String { | |
let thousands = ["", "M", "MM", "MMM"]; | |
let hundreds = ["", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"]; | |
let tens = ["", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"]; | |
let ones = ["", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"]; |
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
const fs = require('node:fs') | |
const path = require('node:path') | |
/** | |
* Traverse files in a dir | |
* @param {string} dirPath Dir path | |
* @param {string[]} ext | |
* @param {number} [deep] | |
* @param {any[]} [collection] | |
*/ |
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 resolveData<T = any>(data: Record<string | number, any>, path: string): T { | |
const pathArr = path.split('.') | |
return path.length === 0 ? data : pathArr.reduce((originalData, path) => originalData[path], data) | |
} |
OlderNewer