Skip to content

Instantly share code, notes, and snippets.

View wkei's full-sized avatar
📷
"click"

Kei wkei

📷
"click"
View GitHub Profile
@wkei
wkei / cmd.md
Last active January 16, 2019 04:08
serve + ngrok + headers config
npm install --global serve ngrok
serve
ngrok http 5000
@wkei
wkei / json2str.js
Created December 20, 2018 06:43
JSON.stringify
const json2str = (target) => {
switch (typeof target) {
case 'number':
return isNaN(target) ? 'null' : target.toString()
case 'boolean':
return target.toString()
case 'string':
return `"${target}"`
case 'object':
if (target === null) {
// https://adventofcode.com/2018/day/8
// https://jsfiddle.net/keipixel/fuyhq4az/
const data = '2 3 0 3 10 11 12 1 1 0 1 99 2 1 1 2'
// {
// meta: [1, 1, 2],
// children: [
// {
// meta: [10, 11, 12],
// children: []
@wkei
wkei / dot-css-notes.md
Last active December 6, 2018 10:16
dotCSS Notes
@wkei
wkei / netrw quick reference.md
Created October 15, 2018 08:19 — forked from t-mart/netrw quick reference.md
A quick reference for Vim's built-in netrw file selector.
Map Action
<F1> Causes Netrw to issue help
<cr> Netrw will enter the directory or read the file
<del> Netrw will attempt to remove the file/directory
- Makes Netrw go up one directory
a Toggles between normal display, hiding (suppress display of files matching g:netrw_list_hide) showing (display only files which match g:netrw_list_hide)
c Make browsing directory the current directory
C Setting the editing window
d Make a directory
@wkei
wkei / HiraginoSans.css
Created August 30, 2018 05:13
japanese font
@font-face {
font-family: "Hiragino Sans";
src: local(HiraginoSans-W0);
font-weight: 100;
}
@font-face {
font-family: "Hiragino Sans";
src: local(HiraginoSans-W1);
font-weight: 200;
}
@wkei
wkei / git-notes.md
Last active January 25, 2019 03:58
GIT

fetch a branch on someone else's fork

$ git remote add theirusername [email protected]:theirusername/reponame.git
$ git fetch theirusername
$ git checkout -b mynamefortheirbranch theirusername/theirbranch

change author name/email

@wkei
wkei / pagination.md
Last active June 1, 2018 08:01
simple pagination principle

principle:

  • always show the first and the lastest page
  • show two preview pages and two next pages of current page

<= 8

  1 2 3 4 5 6 7 8
@wkei
wkei / tips.js
Last active July 12, 2018 09:43
JS Tips
// parse search query
const params = new URLSearchParams('?a=b');
params.get('a')
// querySelector with attribute
document.querySelector('div:not([data-role="head"])')
// online matrix
const matrix = new Array(10).fill(0).map((v, i) => (new Array(10).fill(0).map((vv, ii) => `r${i}c${ii}`)))
@wkei
wkei / string-array.js
Last active April 12, 2022 14:48
String & Array func
var s = 'abcde'
// s.substr(1/*start*/, 3/*count*/) // bcd
s.substring(1/*start*/, 3/*end(not included)*/) // bc, not changed
s.slice(1/*start*/, 3/*end(not included)*/) // bc, not changed
s.slice(1,3) === s.substring(1,3)
var a = ["a", "b", "c", "d", "e"]
a.slice(1/*start*/, 3/*end(not included)*/) // ['b', 'c'], not changed