Skip to content

Instantly share code, notes, and snippets.

View bytemain's full-sized avatar

Jiacheng bytemain

View GitHub Profile
@sindresorhus
sindresorhus / esm-package.md
Last active November 25, 2025 17:53
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.
@felix021
felix021 / socks5_proxy.go
Created November 21, 2020 08:12
Minimal socks5 proxy implementation in Golang
package main
import (
"encoding/binary"
"errors"
"fmt"
"io"
"net"
)
@ChristopherA
ChristopherA / brew-bundle-brewfile-tips.md
Last active November 11, 2025 16:04
Brew Bundle Brewfile Tips

Brew Bundle Brewfile Tips

Copyright & License

Unless otherwise noted (either in this file or in a file's copyright section) the contents of this gist are Copyright ©️2020 by Christopher Allen, and are shared under spdx:Creative Commons Attribution Share Alike 4.0 International (CC-BY-SA-4.) open-source license.

Sponsor

If you more tips and advice like these, you can become a monthly patron on my GitHub Sponsor Page for as little as $5 a month; and your contributions will be multipled, as GitHub is matching the first $5,000! This gist is all about Homebrew, so if you like it you can support it by donating to them or becoming one of their Github Sponsors.

@Scstechr
Scstechr / rand_string.rs
Created May 10, 2020 11:01
Random string generator in Rust
use rand::seq::SliceRandom;
use std::env;
use std::string::FromUtf8Error;
const BASE_STR_ONE: &str =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345678999999999ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345
@miguelgrinberg
miguelgrinberg / .tmux.conf
Last active March 15, 2022 11:39
My .tmux.conf file for working with tmux
# Set the prefix to ^A.
unbind C-b
set -g prefix ^A
bind a send-prefix
# Start windows and panes at 1, not 0
set -g base-index 1
set -g pane-base-index 1
set -g renumber-windows on
@miguelgrinberg
miguelgrinberg / .vimrc
Last active November 19, 2025 18:07
My .vimrc configuration for working in Python with vim
" plugins
let need_to_install_plugins = 0
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
let need_to_install_plugins = 1
endif
call plug#begin()
Plug 'tpope/vim-sensible'
@crazy-max
crazy-max / Caddy.env
Last active January 1, 2025 13:39
Proxmox web interface through Caddy as reverse proxy with Let's Encrypt
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_HOSTED_ZONE_ID=
@slikts
slikts / advanced-memo.md
Last active February 25, 2025 15:19
Advanced memoization and effects in React

nelabs.dev

Advanced memoization and effects in React

Memoization is a somewhat fraught topic in the React world, meaning that it's easy to go wrong with it, for example, by [making memo() do nothing][memo-pitfall] by passing in children to a component. The general advice is to avoid memoization until the profiler tells you to optimize, but not all use cases are general, and even in the general use case you can find tricky nuances.

Discussing this topic requires some groundwork about the technical terms, and I'm placing these in once place so that it's easy to skim and skip over:

  • Memoization means caching the output based on the input; in the case of functions, it means caching the return value based on the arguments.
  • Values and references are unfortunately overloaded terms that can refer to the low-level implementation details of assignments in a language like C++, for example, or to memory
@tomhicks
tomhicks / plink-plonk.js
Last active October 15, 2025 13:41
Listen to your web pages
@jfcherng
jfcherng / st4-changelog.md
Last active November 5, 2025 09:53
Sublime Text 4 changelog just because it's not on the official website yet.