Skip to content

Instantly share code, notes, and snippets.

View zRains's full-sized avatar
🍀
Lucky

zrain zRains

🍀
Lucky
View GitHub Profile
@zRains
zRains / 1024.rs
Created October 23, 2022 16:18
leetcode 1024 Rust implementation
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> {
@zRains
zRains / setting.json
Created September 24, 2022 14:30
My vscode setting
{
"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,
async function async1() {
console.log('async1 start')
new Promise((resolve, reject) => {
try {
throw new Error('error1')
} catch (e) {
console.log(e)
}
setTimeout(() => {
resolve('promise4')
@zRains
zRains / http_status.rs
Created September 23, 2022 09:50
From Nest.js
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,
@zRains
zRains / mineStatus.js
Created September 17, 2022 17:12
Get Minecraft server info by LSP using nodejs.
const { Socket } = require('net')
class MineStatus {
/** @type {Socket} */
socket
/** @type {string} */
host
/** @type {number} */
@zRains
zRains / link.rs
Last active June 1, 2022 12:58
Rust 链表
@zRains
zRains / cs.ts
Last active October 11, 2022 07:21
时效性localStorage简单实现
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 {