Skip to content

Instantly share code, notes, and snippets.


Yoshihide Jimbo jmblog

View GitHub Profile
View useDetectOutsideClick.ts
import { useState, useEffect, RefObject } from 'react';
export const useDetectOutsideClick = (ref: RefObject<HTMLElement>, initialState: boolean) => {
const [isActive, setIsActive] = useState(initialState);
useEffect(() => {
const pageClickEvent = (event: MouseEvent) => {
// If the active element exists and is clicked outside of
if (ref.current !== null && !ref.current.contains( as Node)) {
View nuxt-netlify-http2-server-push-module.js
const debug = require('debug')('nuxt:netlify-http2-server-push');
const path = require('path');
const glob = require('glob');
const fs = require('fs');
module.exports = function module(moduleOptions) {
// This module is only enabled on production builds
if ( {
jmblog / file0.txt
Last active Dec 5, 2017
Vanilla JS や TypeScript で Custom Elements を書く際の注意点 ref:
View file0.txt
Failed to construct 'HTMLElement': Please use the 'new' operator, this DOM object constructor cannot be called as a function.
jmblog / karabiner.json
Last active Nov 12, 2017
かなキーで「英数/かな」のトグル切り替え(Karabiner-Elements 11.1.8以上が必要)
View karabiner.json
"profiles": [
"complex_modifications": {
"rules": [
"description": "Toggle input source (English or Japanese) by kana key (available since Karabiner-Elements 11.1.8)",
"manipulators": [
"conditions": [
View tsconfig.json
"compilerOptions": {
"outDir": "./dist/",
"sourceMap": true,
"noImplicitAny": true,
"strictNullChecks": true,
"removeComments": true,
"module": "commonjs",
"target": "es5",
"jsx": "react"
jmblog / .editorconfig
Created Dec 28, 2016
My .editorconfig
View .editorconfig
root = true
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
jmblog / file0.txt
Last active Nov 7, 2016
CI のビルド時に patch を適用する際の注意点 ref:
View file0.txt
# 1回目
$ patch --batch -p0 -i xxx.patch
patching file node_modules/foo/bar/xxx
# 2回目
$ patch --batch -p0 -i xxx.patch
patching file node_modules/foo/bar/xxx
Reversed (or previously applied) patch detected! Assuming -R. # 元に戻ってしまう
jmblog / bash_prompt
Created May 23, 2014
Bash prompt customization
View bash_prompt
#!/usr/bin/env bash
# Check that terminfo exists before changing TERM var to xterm-256color
# Prevents prompt flashing in Mac OS X 10.6
if [ -e /usr/share/terminfo/x/xterm-256color ]; then
export TERM='xterm-256color'
# Turn off standout; turn off underline
tput sgr 0 0
View navbar.slim
nav class="nav navbar navbar-inverse" role="navigation"
div class="container"
div class="navbar-header"
button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".navbar-gnav-collapse"
span class="sr-only" Toggle navigation
span class="icon-bar"
span class="icon-bar"
span class="icon-bar"
div class="collapse navbar-collapse navbar-gnav-collapse"
ul class="nav navbar-nav"