Skip to content

Instantly share code, notes, and snippets.

@Knovour
Knovour / bopomofo_tw.custom.yaml
Created February 13, 2024 00:09
RIME 注音輸入法 + Dvorak 支援,包含標點符號位置
patch:
punctuator/half_shape:
"!": {commit: "!"}
"\"": {pair: ["“", "”"]}
"#": "#"
"$": ["¥", "$", "€", "£", "¥", "¢", "¤"]
"%": ["%", "%", "°", "℃"]
"&": "&"
"(": "("
")": ")"
@Knovour
Knovour / .eslintrc.json
Created February 25, 2023 02:55
typescript eslint config
{
"env": {
"browser": true,
"es6": true
},
"extends": ["airbnb-typescript", "plugin:prettier/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
@Knovour
Knovour / new_cmd.md
Last active February 15, 2024 04:02
  • cd -> zoxide
  • ls -> exa
  • cat -> bat
  • find -> fd
  • grep -> ripgrep
  • diff -> diff-so-fancy
  • top -> glances
  • vim -> neovim
  • curl -> HTTPie
@Knovour
Knovour / .eslintrc_normal.js
Last active December 6, 2018 16:14
eslintrc
module.exports = {
parser: 'babel-eslint',
env: {
browser: true,
node: true,
commonjs: true,
jest: true,
jquery: true
},
extends: 'airbnb-base',
@Knovour
Knovour / clamp.js
Last active February 21, 2019 02:45
Some JS snippets collection
// Base on https://gist.github.com/kujon/2781489
const clamp = (val, min, max) => {
const realMin = max > min ? min : max
const realMax = max > min ? max : min
return Math.max(realMin, Math.min(realMax, val))
}
'use strict'
const file = {
load(cb) {
let tmp = [];
d3.tsv("data.tsv", (err, list) => {
const length = list.length;
// you CANNOT overwrite tmp with another object, it must be updated with the data.
for(let i = 0; i < length; i++)
tmp[i] = list[i];
@Knovour
Knovour / numberInputArray.js
Last active August 29, 2015 13:56
Be sure that user input is number or number array ex: '2,4,6,1'
// Be sure that user input is number or number array ex: '2,4,6,1'
// Demo:
// http://jsfiddle.net/ED2Ra/6/
// http://codepen.io/Knovour/pen/fFJxi
var keyRegex = /[\d,]$/;
var numberArrayReg = /^((0$|0,)|[1-9]\d*,?)*$/; // (0$|0,) : prevent 00 or 0[1-9]
$('input[type=text]')
.keypress(function(event) {
var iconv = require('iconv-lite');
var buf = iconv.encode('測試', 'big5'); // <buffer B4 FA B8 D5>
var bufLength = buf.length;
var test = '';
for (var i = 0; i < bufLength; i++)
test += '%' + buf[i].toString('16').toUpperCase();
// test = %B4%FA%B8%D5