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 / git-clone-wordpress-latest.sh
Created February 26, 2017 20:32
ワンライナーで Wordpress の最新版タグを git clone
git clone --depth=1 -b $(curl -s https://api.github.com/repos/WordPress/WordPress/tags | grep -m 1 -o -E '[0-9\.]+') https://github.com/WordPress/WordPress.git
@yutahaga
yutahaga / upsert.js
Created March 5, 2017 04:40
sequelize で upsert を行うモジュール。 updateFn を指定すると、登録されているレコードの内容を元に変更を加えることができる。
const upsert = async (model, values, where, updateFn) => {
const obj = await model.findOne({ where });
if (obj) {
if (typeof updateFn === 'function') {
return model.update(updateFn(obj, values), { where });
}
return model.update(values, { where });
}
return model.create(values);
};
@yutahaga
yutahaga / react-loading-indicator.js
Created March 12, 2017 12:24
読み込み中の表示をする React コンポーネント。SVG は CodePen から拝借。 https://codepen.io/aurer/pen/jEGbA
import { Component, PropTypes } from 'react';
class LoadingIndicator extends Component {
static propTypes = {
loading: PropTypes.bool.isRequired,
label: PropTypes.string.isRequired,
color: PropTypes.string,
};
static defaultPropTypes = {
@yutahaga
yutahaga / get_sidebar_widgets.php
Created March 21, 2017 11:27
WordPress で REST API などでの利用目的のためにウィジェットの (設定を含む) 情報を取得する関数です。
/**
* ウィジェット一覧取得
*
* @return array
*/
function get_sidebar_widgets() {
$sidebar_widgets = wp_get_sidebars_widgets();
$sidebar_widgets = array_map(
function ( $widgets ) {
@yutahaga
yutahaga / illustrator-material-shadow-filters.svg
Last active March 30, 2017 14:54
Adobe Illustrator で使える、Material Desigin のシャドウを再現できる SVG フィルターです。コードはこちらから拝借 http://codepen.io/hanger/pen/yOGvQp
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yutahaga
yutahaga / index.php
Created May 6, 2017 04:41
サブディレクトリを WordPress のホームディレクトリにするときの index.php
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
@yutahaga
yutahaga / wp-config.php
Last active November 1, 2017 16:56
APP_ENV で本番・開発環境の設定切り替えするための WordPress 設定ファイル
<?php
/**
* WordPress の基本設定
*
* このファイルは、インストール時に wp-config.php 作成ウィザードが利用します。
* ウィザードを介さずにこのファイルを "wp-config.php" という名前でコピーして
* 直接編集して値を入力してもかまいません。
*
* このファイルは、以下の設定を含みます。
*
@yutahaga
yutahaga / .htaccess
Last active November 1, 2017 16:58
WordPress 用 .htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
@yutahaga
yutahaga / wp-config.php
Last active December 28, 2017 07:43
ローカル用
<?php
/**
* WordPress の基本設定
*
* このファイルは、インストール時に wp-config.php 作成ウィザードが利用します。
* ウィザードを介さずにこのファイルを "wp-config.php" という名前でコピーして
* 直接編集して値を入力してもかまいません。
*
* このファイルは、以下の設定を含みます。
*
@yutahaga
yutahaga / .php_cs
Last active January 15, 2018 04:05
My coding standard
<?php
$rules = [
'@PSR2' => true,
'array_syntax' => [
'syntax' => 'short',
],
'binary_operator_spaces' => [
'align_double_arrow' => true,
'align_equals' => null,