Skip to content

Instantly share code, notes, and snippets.

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

Yuta Haga yutahaga

🏠
Working from home
View GitHub Profile
@yutahaga
yutahaga / .stylelintrc.js
Created March 21, 2019 15:51
Stylelint Configuration for SCSS
// yarn add @primer/css stylelint-config-primer stylelint-config-prettier -D
module.exports = {
extends: ['stylelint-config-primer', 'stylelint-config-prettier']
}
@yutahaga
yutahaga / .htaccess
Last active December 21, 2018 19:36
ManageWP からのアクセスを許可する .htaccess スニペット。
# SetEnvIf Remote_Addr ManageWP AllowCountry
# @See (https://managewp.com/troubleshooting/general/managewp-ips-can-white-list)
SetEnvIf Remote_Addr 34.211.180.66 AllowCountry
SetEnvIf Remote_Addr 54.70.65.107 AllowCountry
SetEnvIf Remote_Addr 34.210.224.7 AllowCountry
SetEnvIf Remote_Addr 52.41.5.108 AllowCountry
SetEnvIf Remote_Addr 52.35.72.129 AllowCountry
SetEnvIf Remote_Addr 35.162.254.253 AllowCountry
SetEnvIf Remote_Addr 52.11.12.231 AllowCountry
SetEnvIf Remote_Addr 52.11.29.70 AllowCountry
@yutahaga
yutahaga / vue.d.ts
Last active December 8, 2018 15:45
@nuxtjs/apollo 用の Vue 拡張宣言ファイル。
/**
* Extends interfaces in Vue.js
*/
import ApolloClient from 'apollo-client'
import { AxiosInstance } from 'axios'
import Vue, { ComponentOptions } from 'vue'
import { VueApollo } from 'vue-apollo/types/vue-apollo'
import { Route } from 'vue-router'
import { MetaInfo } from 'vue-meta'
// 公式 dev ブランチの index.d.ts を nuxt.d.ts として配置。
@yutahaga
yutahaga / vue-apollo.d.ts
Created December 8, 2018 15:34
@nuxtjs/apollo用の VueApollo 型拡張宣言ファイル。
declare module 'vue-apollo/types/vue-apollo' {
import { ApolloClient } from 'apollo-client'
import {
VueApolloOptions,
WatchLoading,
ErrorHandler
} from 'vue-apollo/types/options'
interface VueApollo {
defaultClient: ApolloClient<{}>
@yutahaga
yutahaga / scss-functions.js
Created December 7, 2018 14:22
SCSS に JavaScript の変数を読み込む関数を追加する(Tailwind.css)。 参考: https://itnext.io/sharing-variables-between-js-and-sass-using-webpack-sass-loader-713f51fa7fa0
const config = require('./tailwind')
module.exports = {
'config($keys)': function(keys) {
const sass = require('node-sass')
const sassUtils = require('node-sass-utils')(sass)
const convertStringToSassDimension = function(result) {
// Only attempt to convert strings
if (typeof result !== 'string') {
@yutahaga
yutahaga / enter-observer.ts
Last active November 10, 2021 08:40
Intersection Observer を使った侵入監視クラス。default export でシングルトンに使えるインスタンスを提供。
export type EnterObserverListener = (
entry: IntersectionObserverEntry
) => void | Promise<void>;
export interface EnterObserverEntry {
listener: EnterObserverListener;
once: boolean;
}
export class EnterObserver {
@yutahaga
yutahaga / listener.ts
Last active August 7, 2018 14:32
Passive Event Listeners Helpers
/**
* Used to detect browser support for adding an event listener with options
* Credit: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
*/
let supportsCaptureOption = false;
try {
const opts = Object.defineProperty({}, 'capture', {
get() {
supportsCaptureOption = true;
@yutahaga
yutahaga / webpack.config.js
Created May 11, 2018 20:52
TypeScipt + @storybook/vue + @vue/cli 構成用の Webpack 設定ファイル。@vue/cli@3.0.0-beta.10 + webpack@4.8.2 + vue-loader@15.0.10 でビルド確認済み。
const merge = require('webpack-merge');
const vueConfig = require('@vue/cli-service/webpack.config.js');
module.exports = (storybookConfig, configType) => {
return {
...vueConfig, // use vue's webpack configuration by default
entry: storybookConfig.entry, // overwite entry
output: storybookConfig.output, // overwrite output
// remove duplicated plugins
plugins: merge({
<?php
/**
* Plugin Name: WP REST API filter parameter
* Description: This plugin adds a "filter" query parameter to API post collections to filter returned results based on public WP_Query parameters, adding back the "filter" parameter that was removed from the API when it was merged into WordPress core.
* Author: WP REST API Team
* Author URI: http://v2.wp-api.org
* Version: 0.1
* License: GPL2+
**/
@yutahaga
yutahaga / heifc
Last active January 25, 2018 05:35
#!/bin/bash
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-c|--crf)
CRF="$2"