Skip to content

Instantly share code, notes, and snippets.

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

Kei wkei

📷
"click"
View GitHub Profile
function intToBase16(num) {
if (num === 0) return '0'
const digits = Array.from(new Array(16), (_, i) => i < 10 ? i : String.fromCharCode(65 + i - 10))
let base16 = ''
while (num !== 0) {
base16 = digits[num % 16] + base16
num = Math.floor(num / 16)
}
return base16
}
@wkei
wkei / use-cache-fetcher.ts
Created February 9, 2022 02:44
react hooks
// fetch with caches api
import { useState, useEffect, useRef } from 'react';
export default function useCacheFetche(cacheId: string) {
const fetcher = <T>(url: string) => {
const [data, setData] = useState<T | null>(null);
const [error, setError] = useState(null);
const cacheRef = useRef<Cache | null>(null);
@wkei
wkei / unfollow-nonfollower.js
Last active March 17, 2021 04:00 — forked from JamieMason/unfollow.js.md
Unfollow non-follower on twitter.com
// Unfollow everyone on twitter.com, by Jamie Mason (https://twitter.com/fold_left)
// https://gist.github.com/JamieMason/7580315
//
// 1. Go to https://twitter.com/YOUR_USER_NAME/following
// 2. Open the Developer Console. (COMMAND+ALT+I on Mac)
// 3. Paste this into the Developer Console and run it
//
// Last Updated: 17 March 2021
(() => {
const $followButtons = '[data-testid$="-unfollow"]';
@wkei
wkei / useWheel.ts
Created March 10, 2020 04:38
useWheel.ts
import { useState, useLayoutEffect } from 'react';
interface UseWheelType {
deltaX: number;
deltaY: number;
}
const useWheel = (ref: React.RefObject<HTMLDivElement>): UseWheelType => {
const [deltaX, setDeltaX] = useState<number>(0);
const [deltaY, setDeltaY] = useState<number>(0);
@wkei
wkei / App.svelte
Last active December 24, 2019 09:18
Svelte built bundle js, only 300 lines...
<script>
export let count = 0
$: doubled = count * 2
</script>
<main>
<h1>doubled count: {doubled}!</h1>
<button on:click={() => count ++}>add</button>
</main>
@wkei
wkei / 1.md
Last active September 3, 2019 07:47
test

1 image

@wkei
wkei / .bash_profile
Last active July 16, 2019 02:22
dotfiles
export PS1="\W \\$ "
# alias
alias ..="cd .."
alias ...="cd ../.."
alias l="ls -Ga"
alias zshrc="vim ~/.zshrc"
alias gs="git status"
alias gb="git branch"
alias gl="git log"
@wkei
wkei / TUIAPPs.md
Last active June 17, 2019 03:48
Collection for Text-Based User Interface Application
@wkei
wkei / editable.vue
Last active June 12, 2019 01:49
editable.vue
<template>
<editable
:editable="editable"
target="aaa.bbb.ccc"
@handler="handler"
>
<slot name="read"></slot>
<slot name="edit"></slot>
<slot name="message"></slot>
</editable>
@wkei
wkei / circleci.yml
Created May 7, 2019 10:27
CircleCI
#https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs
version: 2.1
jobs:
build:
docker:
- image: circleci/node:10.15.3
working_directory: ~/test-ci
steps: