Skip to content

Instantly share code, notes, and snippets.

View royswale's full-sized avatar
💕
TypeScript & Go & Rust

royswale

💕
TypeScript & Go & Rust
View GitHub Profile
@rmorse
rmorse / react-router-dom-v.6.02.prompt.blocker.js
Last active January 12, 2026 13:14
Adds back in `useBlocker` and `usePrompt` to `react-router-dom` version 6.0.2 (they removed after the 6.0.0 beta, temporarily)
/**
* These hooks re-implement the now removed useBlocker and usePrompt hooks in 'react-router-dom'.
* Thanks for the idea @piecyk https://github.com/remix-run/react-router/issues/8139#issuecomment-953816315
* Source: https://github.com/remix-run/react-router/commit/256cad70d3fd4500b1abcfea66f3ee622fb90874#diff-b60f1a2d4276b2a605c05e19816634111de2e8a4186fe9dd7de8e344b65ed4d3L344-L381
*/
import { useContext, useEffect, useCallback } from 'react';
import { UNSAFE_NavigationContext as NavigationContext } from 'react-router-dom';
/**
* Blocks all navigation attempts. This is useful for preventing the page from
* changing until some condition is met, like saving form data.
@pekkavaa
pekkavaa / extending csv.md
Last active November 13, 2022 01:07
A Straightforward Way To Extend CSV With Metadata

A Straightforward Way To Extend CSV With Metadata

Pekka Väänänen, Aug 19 2021.

This proposal is a response to It's Time to Retire the CSV by Alex Rasmussen and the discussion on lobste.rs. Don't take it too seriously.

CSV files (comma-separated values) are great but sometimes difficult to parse because everybody seems to have a slightly different idea what CSV means. The obvious solution is to transmit some metadata that tells what to expect but where do you put it? Well, how about a ZIP archive?

An archive with two files. The first file, say format.txt, has the metadata inside and the second one is the original CSV file unchanged. This is still readable by non-technical users because ZIP files are natively supported by both Windows and macOS. People can double click on them like a directory and then double click again on the CSV to open it up in Excel.

@Zxilly
Zxilly / gsoc-2021.md
Last active November 24, 2021 07:03
@sindresorhus
sindresorhus / esm-package.md
Last active March 16, 2026 04:38
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@defclass
defclass / jd.md
Last active March 1, 2023 08:44
开源笔记 Logseq 远程团队招聘两位开发工程师 [已结束]

开源笔记 Logseq 远程团队招聘两位开发工程师 [已结束]

v2ex帖子地址

cnodejs帖子地址

工作时间,方式,内容与待遇

  • 全员远程,WFH,WLB。
@m-radzikowski
m-radzikowski / script-template.sh
Last active February 27, 2026 03:13
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@hantsy
hantsy / ModifiedDockerfile.xe
Created August 14, 2020 08:58
A modified dockerfile.xe to install oracle database 18.4.0 from local disc.
# LICENSE UPL 1.0
#
# Copyright (c) 2018, 2020 Oracle and/or its affiliates.
#
# ORACLE DOCKERFILES PROJECT
# --------------------------
# This is the Dockerfile for Oracle Database 18c Express Edition
#
# REQUIRED FILES TO BUILD THIS IMAGE
# ----------------------------------
@chinatimeline
chinatimeline / python-telegram-bot-tutorial.md
Last active October 22, 2024 02:27
开发和部署Telegram Bot的文章

开发和部署Telegram Bot的文章

如果你也想开发自己的电报机器人,類似這個,这里有几篇很有帮助的技术文章。

  1. Learn to build your first bot in Telegram with Python 这是最好的入门示例,而且作者提供了github repo,如果你熟悉Python这门世界上最流行的编程语言,可以照着文章做一遍,就能创建一个简单的回复你狗狗图片的机器人了。
  2. How I wrote a Telegram bot for Bitbucket using Heroku and Python. 这篇博文很短,但是它提到了两篇文章一步步介绍如何部署你的机器人到heroku的免费计划,非常实用。
  3. 第三篇属于进阶篇,其实只是Github上一段python代码,但是它包含了如何利用有限状态机(FSM)来处理对话中的复杂逻辑,要开发正经点的功能的话,这是绝佳基线代码。
  4. 当然不能忘了推荐这个python库,开发python电报机器人必备库。
@asyncins
asyncins / snowflake.go
Created July 3, 2020 05:59
[snowflake-go]
package main
import (
"errors"
"fmt"
"sync"
"time"
)
const (
@alaminfirdows
alaminfirdows / Encryption.js
Created April 5, 2020 18:48 — forked from ve3/Encryption.js
Encrypt and decrypt between programming languages (PHP & JavaScript).
/**
* Encryption class for encrypt/decrypt that works between programming languages.
*
* @author Vee Winch.
* @link https://stackoverflow.com/questions/41222162/encrypt-in-php-openssl-and-decrypt-in-javascript-cryptojs Reference.
* @link https://github.com/brix/crypto-js/releases crypto-js.js can be download from here.
*/
class Encryption {