Skip to content

Instantly share code, notes, and snippets.

View kawarimidoll's full-sized avatar
🫠
I hope everyone is in peace

カワリミ人形 kawarimidoll

🫠
I hope everyone is in peace
View GitHub Profile
@kawarimidoll
kawarimidoll / README.md
Last active January 19, 2022 04:40
Number formatter for display in Japanese

jpNumberFormat.js

数値を日本語の文章中で見やすい形式に桁区切りします。

  • 4桁ごとになどの日本語の区切りを挟みます。
    • までしか用意していないので、それより大きな数値は正しく表現できません。
    • 小数点以下はそのまま表示します。
  • 千の桁には,を追加します。
    • これが不要である場合、出力結果に.replaceAll(",", "")を適用することで削除できます。
@kawarimidoll
kawarimidoll / lazy-treesitter.vim
Created June 22, 2022 23:10
lazy load nvim-treesitter using vim-plug
" vim-plug
call plug#begin(stdpath('config') . '/plugged')
Plug 'catppuccin/nvim', {'as': 'catppuccin'}
Plug 'nvim-treesitter/nvim-treesitter', { 'do': ':TSUpdate', 'on': [] }
Plug 'andymass/vim-matchup', { 'on': [] }
call plug#end()
" enable treesitter-integrated colorscheme
colorscheme catppuccin
@kawarimidoll
kawarimidoll / README.md
Last active November 28, 2022 02:40
Wrap around the edges of the quickfix list.

CCycle

An expanded qprevious and qnext that wrap around the edges of the quickfix list.

Type [q to open previous quickfix, type ]q to open next quickfix. You can use counts, for example, type 2[q to open second previous quickfix.

You can use old revision if you don't need counts.

@kawarimidoll
kawarimidoll / highlight_extra_whitespaces.vim
Last active August 13, 2022 23:44
Highlight extra whitespaces in Vim
" Highlight extra whitespaces
" https://zenn.dev/kawarimidoll/articles/450a1c7754bde6
" u00A0 ' ' no-break space
" u2000 ' ' en quad
" u2001 ' ' em quad
" u2002 ' ' en space
" u2003 ' ' em space
" u2004 ' ' three-per em space
" u2005 ' ' four-per em space
" u2006 ' ' six-per em space
@kawarimidoll
kawarimidoll / which-key-ins-completion.lua
Last active July 10, 2022 05:44
Show sources of ins-completion by which-key.nvim
local wk = require("which-key")
wk.setup()
-- :h ins-completion
wk.register({
["<C-l>"] = 'Whole lines',
["<C-n>"] = 'keywords in the current file',
["<C-k>"] = 'keywords in dictionary',
["<C-t>"] = 'keywords in thesaurus',
@kawarimidoll
kawarimidoll / three-characters-timestamp.ts
Created July 23, 2022 22:59
generate three characters timestamp that is sortable
export function threeCharactersTimestamp(date?: Date) {
if (!date) {
date = new Date();
}
const [h, m, s] = [date.getHours(), date.getMinutes(), date.getSeconds()];
// min & sec eatch 4 seconds
const ms = Math.floor((m * 60 + s) / 4);
const [m2, s2] = [Math.floor(ms / 30), ms % 30];
@kawarimidoll
kawarimidoll / git-sw.sh
Created July 24, 2022 04:20
Smart git-switch using fzf
#!/bin/bash
# Save this file as `git-sw` in your $PATH and run `chmod +x git-sw`.
# Run `git sw -` to switch to last branch.
# Run `git sw` to select branch using fzf.
# Run `git sw branch-name` to pass query to fzf.
# If the argument is matched to existing branch, change to that immediately.
# Create new branch when query is not matched by `fzf --print-query | tail -1`.
# ref: https://github.com/junegunn/fzf/issues/1693#issuecomment-699642792
@kawarimidoll
kawarimidoll / roman_kana_table.lua
Created September 11, 2022 05:13
generate romaji-kana table for japanese input
-- https://support.microsoft.com/ja-jp/topic/%E3%83%AD%E3%83%BC%E3%83%9E%E5%AD%97%E5%85%A5%E5%8A%9B%E3%81%AE%E3%81%A4%E3%81%A5%E3%82%8A%E4%B8%80%E8%A6%A7%E8%A1%A8%E3%82%92%E7%A2%BA%E8%AA%8D%E3%81%97%E3%81%A6%E3%81%BF%E3%82%88%E3%81%86-bcc0ad7e-2781-cc9a-e524-7de506d8fdae
local roman_kana_table = {
-- common symbols in japanese writings
['~'] = '~', [','] = '、', ['.'] = '。', ['/'] = '・',
['-'] = 'ー', ['['] = '「', [']'] = '」',
-- other full-space symbols
-- ['!']='!', ['"']='”', ['#']='#', ['$']='$', ['%']='%',
-- ['&']='&', [''']='’', ['(']='(', [')']=')', ['*']='*',
-- ['+']='+', [',']=',', ['-']='-', ['.']='.', ['/']='/',
@kawarimidoll
kawarimidoll / get_current_dot_chained_word.vim
Created September 11, 2022 06:50
get function call or property under current cursor position that chained by dots
let col = getcurpos('.')[2]
let line = getline('.')
let pre = substitute(line[:col-1], '^.*[^0-9A-Za-z_.]', '', '')
let post = substitute(line[col:], '[^0-9A-Za-z_.].*$', '', '')
echo pre .. post
@kawarimidoll
kawarimidoll / fz-gist.sh
Last active November 28, 2022 13:37
edit or view gist by fzf and gh-cli
# define in your .bashrc or .zshrc
# fuzzy edit gist
fest() {
gh gist list "$@" | fzf --with-nth=-2,-4,-3,2..-5 | awk '{print $1}' \
| xargs --no-run-if-empty --open-tty gh gist edit
}
# view web gist
vest() {