Skip to content

Instantly share code, notes, and snippets.

View towry's full-sized avatar
🎯
Focusing

Towry Wang towry

🎯
Focusing
View GitHub Profile
@OrionReed
OrionReed / dom3d.js
Last active May 17, 2024 08:27
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯
@MlsDmitry
MlsDmitry / guide.md
Last active January 3, 2024 01:49
MacOs Guide: determine hex code sequence for key combinations
  1. Ctrl + F keys and a lot of other key combinations are hooked by MacOs. You're mostly don't use them, so just turn everything off in System Preferences -> Keyboard -> Shortcuts. If you have another software that handles your key combinations, like Keyboard Maestro, you should turn these actions/macros off, otherwise you won't get right hex sequence.

  2. Enter command below in default MacOs Terminal. (Warning!: shortcuts can also be hooked by terminal emulators, like iTerm. To avoid it use default MacOs terminal. If you are on alacritty, you can enter alacritty --print-events and use poped up terminal).

xxd -psg

then type your key combination and hit enter. (Warning!: if you don't see any output for your combination, then read step 1 again)

@davidteren
davidteren / nerd_fonts.md
Last active May 16, 2024 20:00
Install Nerd Fonts via Homebrew [updated & fixed]
@Integralist
Integralist / Examples.md
Last active February 7, 2024 22:56
[vim search and replace content using native vim cdo and cfdo commands] #vim #replace #macro #quickfix

There are two 'types' to be aware of with a quickfix window:

  1. entry: the actual line content (e.g. :grep foo will show a specific line that matched within a file).
  2. file: the actual file itself (e.g. the path to the file that contained the match).

To replace content using vim (via the quickfix window) you need to choose whether you want to apply the change via the quickfix 'entry' or via the 'file' as a whole.

If you use cdo, then your 'action' (i.e. how you're going to replace content) will be applied to every entry in the quickfix window.

If you use cfdo, then your action will be applied to each file in the quickfix window.

#![warn(rust_2018_idioms)]
#[derive(Debug)]
pub struct StrSplit<'haystack, D> {
remainder: Option<&'haystack str>,
delimiter: D,
}
impl<'haystack, D> StrSplit<'haystack, D> {
pub fn new(haystack: &'haystack str, delimiter: D) -> Self {
@bbqtd
bbqtd / macos-tmux-256color.md
Last active May 13, 2024 20:04
Installing tmux-256color for macOS

Installing tmux-256color for macOS

  • macOS 10.15.5
  • tmux 3.1b

macOS has ncurses version 5.7 which does not ship the terminfo description for tmux. There're two ways that can help you to solve this problem.

The Fast Blazing Solution

Instead of tmux-256color, use screen-256color which comes with system. Place this command into ~/.tmux.conf or ~/.config/tmux/tmux.conf(for version 3.1 and later):

@rust-play
rust-play / playground.rs
Created August 20, 2019 01:01
Code shared from the Rust Playground
#![allow(dead_code)]
// Suppose we have a shared context for a lot of values, in this specific case,
// this is a shared lua_State for lots of values which live in the lua registry.
struct Lua;
// This is a representation of a value that lives in that shared context. In
// the real api, this is an enum that can represent any lua value, and most
// instances of it are handles to something that points to the lua registry,
// so logically it would hold a reference to the shared Lua state.
@andersevenrud
andersevenrud / alacritty-tmux-vim_truecolor.md
Last active May 17, 2024 15:14
True Color (24-bit) and italics with alacritty + tmux + vim (neovim)

True Color (24-bit) and italics with alacritty + tmux + vim (neovim)

This should make True Color (24-bit) and italics work in your tmux session and vim/neovim when using Alacritty (and should be compatible with any other terminal emulator, including Kitty).

Testing colors

Running this script should look the same in tmux as without.

curl -s https://gist.githubusercontent.com/lifepillar/09a44b8cf0f9397465614e622979107f/raw/24-bit-color.sh >24-bit-color.sh
@Tamal
Tamal / git-ssh-error-fix.sh
Last active May 8, 2024 15:47
Solution for 'ssh: connect to host github.com port 22: Connection timed out' error
$ git clone git@github.com:xxxxx/xxxx.git my-awesome-proj
Cloning into 'my-awesome-proj'...
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.
$ # This should also timeout
$ ssh -T git@github.com
ssh: connect to host github.com port 22: Connection timed out
$ # but this might work
@ChunMinChang
ChunMinChang / Makefile
Last active October 18, 2021 07:02
opaque or transparent interface of the external library
all:
# Build a static library from the Rust file
rustc --crate-type=staticlib ext.rs
# Compile the C file with the static library
# gcc -o sample-c sample.c libext.a
gcc -o sample-c sample.c -L. -lext
./sample-c
# g++ -o sample-cpp sample.cpp libext.a
g++ -o sample-cpp sample.cpp -L. -lext
./sample-cpp