Skip to content

Instantly share code, notes, and snippets.

View hideokamoto's full-sized avatar

Hidetaka Okamoto hideokamoto

View GitHub Profile
@hideokamoto
hideokamoto / redirect_to_spa.php
Created August 10, 2018 04:08
ログインしていない時は、SPAに強制リダイレクト
add_action( 'init', 'redirect_to_spa' );
function redirect_to_spa() {
if ( ! is_user_logged_in() ) {
$uri = $_SERVER["REQUEST_URI"];
if ( ! preg_match( '/^\/wp-login.php/', $uri ) && ! preg_match( '/^\/wp-admin/', $uri ) && ! preg_match( '/^\/wp-json/', $uri ) && ! preg_match( '/^\/feed/', $uri ) ) {
$url = 'https://wp-kyoto.net' . $uri;
wp_redirect( $url, 301 );
exit();
}
}
@hideokamoto
hideokamoto / result
Last active July 2, 2018 02:31
Swaggerの定義情報を読むスクリプト。
React Router Path: /v1/domains/{:domain}
API Path: PUT /v1/domains/{domain}
Parameters
name: domain
in: path
required: true
type: string
React Router Path: /v1/domains/{:domain}
@hideokamoto
hideokamoto / ask-sdk.test.js
Created June 23, 2018 12:36
ask-sdk-coreを使った実装のユニットテストコードサンプル
const Alexa = require('ask-sdk-core');
const { BaseSkillFactory } = Alexa;
const assert = require('power-assert')
const { handler , HelpIntentHandler } = require('../../index.js')
const event = {
session: {
new: true,
sessionId: 'amzn1.echo-api.session.[unique-value-here]',
attributes: {},
user: {
// 入力と出力でマークアップを変えたりするサンプル
import classnames from 'classnames';
const { __, sprintf } = wp.i18n;
const { registerBlockType } = wp.blocks;
const { Fragment } = wp.element;
const {
PanelBody,
Button
} = wp.components;
'use strict';
// Alexa-sdkを取得します
const Alexa = require('alexa-sdk');
// Alexa SkillのIDを指定します。(省略可)
const APP_ID = '';
// リクエスト内容から、nameスロットの値を取り出す処理
const getName = (event) => {
if (!event.request.intent) return '';
if (!event.request.intent.slots.name.value) return '';
{
"schedule": [
{
"date": "2047-05-17",
"groups": [
{
"time": "8:00 am",
"sessions": [
{
"name": "開場",
@hideokamoto
hideokamoto / c3-disabled-cron.php
Created March 13, 2018 08:18
C3 CloudFront Cache Controllerのcronリトライを無効化する
<?php
/**
* @package c3-cloudfront-clear-cache
* @version 0.1
*/
/*
Plugin Name: C3 Disabled cron retry
Plugin URI: https://gist.github.com/
Description: Disabled to regist retry action to wp-cron.
Version: 0.1
<table class="wcpt-schedule" border="0">
<thead>
<tr>
<th class="wcpt-col-time">時間</th>
<th class="wcpt-col-track"> <span class="wcpt-track-name">会議室5a</span> <span class="wcpt-track-description"></span>
</th><th class="wcpt-col-track"> <span class="wcpt-track-name">会議室5b</span> <span class="wcpt-track-description"></span> </th>
<th class="wcpt-col-track"> <span class="wcpt-track-name">講堂</span> <span class="wcpt-track-description"></span> </th>
</tr>
</thead>
<?php
/**
* Plugin Name: admin tracker
* Plugin URI: https://wp-kyoto.net
* Description: tracker
* Version: 0.0.1
* Author: Hidetaka Okamoto
* Author URI: https://wp-kyoto.net
* License: GPLv2+
import React from 'react';
const { __ } = wp.i18n;
const {
registerBlockType,
Editable,
MediaUploadButton,
source: {
attr,
children
}