Skip to content

Instantly share code, notes, and snippets.

View arayaryoma's full-sized avatar
🏠
Working from home

araya arayaryoma

🏠
Working from home
View GitHub Profile
@arayaryoma
arayaryoma / node-ts-init
Created December 11, 2019 07:36
Bash script to initialize a Node.js project with TypeScript, eslint and prettier
#!/bin/bash
yarn init -y
yarn add -D typescript prettier eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-config-prettier eslint-plugin-prettier
curl -slw "\n" https://www.gitignore.io/api/node,macos,windows,linux >> .gitignore
tsc --init
@arayaryoma
arayaryoma / HTML_isn't_done.txt
Last active December 2, 2019 19:18
Chrome Dev Summitまとめ
Edge & Chrome form control collaboration
input要素などの刷新
<meter>のグラデーションは1990sのままらしい
chrome://flags/#form-controls-refresh
windowsのHigh contrast mode
@media(forced-colors: active)
forced-color-adjust: auto | none
Edgeチームがform controlsの改善のために36のaccessibilityに関してのcommitをchromiumに入れた
Stylability
@arayaryoma
arayaryoma / asyncForEach.ts
Created November 14, 2019 14:53
Frequently used utility functions for TypeScript
const asyncForEach = async <T>(array: T[], callback: (item: T, index?: number) => Promise<unknown>): Promise<void> => {
for (let i = 0; i < array.length; i++) {
await callback(array[i], i);
}
return
};
@arayaryoma
arayaryoma / hotReload.ts
Created October 28, 2019 17:36
A background script to enable hot reloading for chrome extension development
const filesInDirectory = async (dir: DirectoryEntry): Promise<File[]> => {
return new Promise(async resolve => {
const entries = await readEntries(dir)
return Promise.all(
entries
.filter(e => e.name[0] !== '.')
.map(e => {
if (isDir(e)) {
return filesInDirectory(e)
} else if (isFile(e)) {
const readdirRecursively = async (dir, files = []) => {
const dirents = await fsPromises.readdir(dir, {withFileTypes: true});
const dirs = [];
for (let dirent of dirents) {
if (dirent.isDirectory()) dirs.push(`${dir}/${dirent.name}`);
if (dirent.isFile()) files.push(`${dir}/${dirent.name}`);
}
for (let d of dirs) {
files = readdirRecursively(d, files)
}
@arayaryoma
arayaryoma / README.md
Last active March 19, 2019 12:55
国土交通省が公開しているAPI( http://www.land.mlit.go.jp/webland/api.html )から市区町村のコードを全都道府県分取得してjsonにする

How to use

node ./city-search.js > result.json
@arayaryoma
arayaryoma / break-points.styl
Created December 27, 2018 10:19
Stylus file to define break-points for responsive web sites
$xs-max = 575px
$sm-min = 576px
$sm-max = 767px
$md-min = 768px
$md-max = 991px
$lg-min = 992px
$lg-max = 1199px
$xl-min = 1200px
xs-screen()
@arayaryoma
arayaryoma / google-forms-to-slack.js
Last active August 15, 2018 09:26
EN: Google App Script to send answers of google forms to Slack (Incoming Webhook) / JA: Google Formsの回答をSlackのIncoming Webhookを使ってSlackに通知するGAS
function onFormSubmit(event) {
try {
var itemResponses = event.response.getItemResponses();
var fields = [];
for(var i = 0; i < itemResponses.length; i++) {
var itemResponse = itemResponses[i];
var title = itemResponse.getItem().getTitle();
var res = itemResponse.getResponse();
fields.push(generateAttachmentField(title, res));
}
@arayaryoma
arayaryoma / index.ts
Created May 3, 2018 08:14
How to use nanoid with TypeScript
import nanoid from 'nanoid';
console.log(nanoid());
@arayaryoma
arayaryoma / pixiv-checkbox-tool.js
Created October 16, 2017 06:17
Check all checkboxes in your bookmark page of Pixiv
for(const i of document.querySelectorAll('.image-item .input-container input[name="book_id[]"]')) {
i.click()
}