Skip to content

Instantly share code, notes, and snippets.

View yuta0801's full-sized avatar

yuta yuta0801

View GitHub Profile
@yuta0801
yuta0801 / useBlur.ts
Created September 16, 2019 06:49
React useEvent hook
import { RefObject } from 'react'
import useEvent from './useEvent'
type Ref = RefObject<Element>
const useBlur = (ref: Ref, callback: () => void) => {
useEvent(ref, 'blur', () => setTimeout(callback))
}
export default useBlur
// ==UserScript==
// @name Wired Normalizer
// @namespace https://github.com/bromne/wired-normalizer
// @version 1.3.0
// @description WIRED.jp の記事に含まれる「ヴ」を、適当なバ行の文字に変換します。
// @author @bromne, @yuta0801
// @match *://wired.jp/*
// @grant none
// @require //ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js
// ==/UserScript==
@yuta0801
yuta0801 / factorio-server-check.nipp.js
Created October 20, 2019 13:52
A Nipp to check Factorio server status
!(async () => {
document.getElementById('app').style.display = 'none'
document.write('読み込み中...')
const server = 'server_id'
const cors = 'https://cors-anywhere.herokuapp.com/'
const url = cors + 'https://multiplayer.factorio.com/get-game-details/' + server
const data = await fetch(url, { headers: { origin: 'any' } }).then(res => res.json())
function nativeApLoginStart() {
const [d, a] = installVersionCheck(false)
if (d && a) return
const dialogMap = {
Win: {
IE: '#ieInstallDialog',
Edge: '#edgeInstallDialog',
Chrome: '#chromeInstallDialog',
TypeScript 1 min █████████████████████ 100.0%
🗣 Commented on #7 in yuta0801/scrapbox-reader
🎉 Merged PR #5 in yuta0801/scrapbox-reader
🎉 Merged PR #6 in yuta0801/scrapbox-reader
🗣 Commented on #5 in yuta0801/scrapbox-reader
🎉 Merged PR #4 in yuta0801/scrapbox-reader
@yuta0801
yuta0801 / .hyper.js
Last active December 8, 2019 22:30
My Hyper config
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',
@yuta0801
yuta0801 / tagsta.sh
Created December 26, 2019 17:11
Tagging commit like stash/a2c2b7d/0
HASH=$(git rev-parse --short HEAD)
PREFIX="stash/$HASH"
function exist() {
git rev-parse $1 >/dev/null 2>&1
}
for i in {0..9}; do
if exist "$PREFIX/$i"; then
continue
function getXpath(element) {
if(!element || !element.parentNode) return ''
let xpath = getXpath(element.parentNode) + '/' + element.tagName
const elements = []
for(const e of element.parentNode.childNodes) {
if(e.tagName == element.tagName) elements.push(e)
}
if(1 < elements.length) {
const i = elements.indexOf(element)
xpath += '[' + (i+1) + ']'
@yuta0801
yuta0801 / p2p.plantuml
Created April 7, 2020 04:45
Piping Server上でP2P通信をするときの流れ
@startuml p2p
group クライアント数だけ繰り返す
Uploader -> Server : /:randomにtokenを生成してPOST
Uploader --> Downloader : /:randomを教える
Downloader -> Server : /:randomをGETし:tokenを取得
group ファイル数分繰り返す
Uploader -> Server : /:random/:tokenをGET
Downloader -> Server : /:random/:tokenに欲しいfileをPOST
Downloader -> Server : /:random/:token/:fileをGET