Skip to content

Instantly share code, notes, and snippets.

View hideokamoto's full-sized avatar

Hidetaka Okamoto hideokamoto

View GitHub Profile
@hideokamoto
hideokamoto / twilio-call.php
Created May 29, 2015 12:36
Twillo Shorcode Plugin
<?php
require('Services/Twilio.php');
function twilio_call(){
$account_sid = "";
$auth_token = "";
$from_num = "+81";
$to_num = "+81";
$twiml_url = "";
$client = new Services_Twilio($account_sid, $auth_token);
@hideokamoto
hideokamoto / file0.txt
Created June 9, 2015 09:54
Polymer1.0でのデータの流れをメモる ref: http://qiita.com/motchi0214/items/1d8751fc63e6fbaa86dd
<!-- 呼び出し部分 -->
<layout-header
title="Quick Start Sample"
desc="Here is Initial Sample Pages.">
</layout-header>
<!-- コンポーネント -->
<dom-module id="layout-header">
<template>
<?php
add_action('admin_menu', 'sparql_hooks');
add_action('save_post', 'save_sparql');
add_action('wp_footer','insert_custom_js');
function get_sparql_data(){
$sparql = get_post_meta(get_the_ID(), '_sparql', true);
$sparql = urlencode($sparql);
$sparql_url = "http://ja.dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fja.dbpedia.org&query={$sparql}&format=application%2Fsparql-results%2Bjson&timeout=0";
return $sparql_url;
<?php
/*
Plugin Name: CloudFront Host Fix
Plugin URI:
Description: CloudFront & Nginx Reverse Proxy Cache fix.
Version: 0.1
Author:
Author URI:
*/
add_action('redirect_canonical', 'change_requested_url');
#!/bin/bash
INSTANCEID=`/usr/bin/curl -s http://169.254.169.254/latest/meta-data/instance-id`
VHOSTS_DIR='/var/www/vhosts'
cd $VHOSTS_DIR
mkdir $INSTANCEID
cd $INSTANCEID
mkdir "wp-content"
cd "wp-content"
mkdir 'mu-plugins'
cd 'mu-plugins'
#!/bin/sh
wp_url="http://YOUR-SITE.DOMAIN/wp-json/wp/v2/posts"
es_url="https://search-YOUR-DOMAIN-XXXXXX.ap-northeast-1.es.amazonaws.com/wp/posts/"
filename="sample.json"
wget -O ${filename} ${wp_url}
posts=$(cat ${filename} | jq ".[].id")
count=0
for post in ${posts}; do
echo ${es_url}${post}
cat ${filename} | jq ".[${count}]" > "${count}.json"
@hideokamoto
hideokamoto / file0.txt
Created December 23, 2015 15:09
様々なコマンド達を何も考えずにWP REST APIとつないで遊ぶ ref: http://qiita.com/motchi0214/items/8a4e9f37d298777adee1
#!/bin/sh
URL=${1}
if [ "${URL}" = "" ]; then
echo "Please set URL"
exit 1
fi
curl -XGET ${URL}"wp-json/wp/v2/posts" | jq ".[0].title.rendered" | cowsay
{
"formatVersion": "v1.0",
"disclaimer": "This pricing list is for informational purposes only. All prices are subject to the additional terms included in the pricing pages on http://aws.amazon.com. All Free Tier prices are also subject to the terms included at https://aws.amazon.com/free/",
"publicationDate": "2016-01-07T05:56:50Z",
"offers": {
"AmazonS3": {
"offerCode": "AmazonS3",
"versionIndexUrl": "/offers/v1.0/aws/AmazonS3/index.json",
"currentVersionUrl": "/offers/v1.0/aws/AmazonS3/current/index.json"
},
@hideokamoto
hideokamoto / file0.txt
Created January 22, 2016 06:15
CloudWatch Logs からElasticsearch Serviceに送るログのインデックス名を変える ref: http://qiita.com/motchi0214/items/5671c6f1a10655236b34
payload.logEvents.forEach(function(logEvent) {
var timestamp = new Date(1 * logEvent.timestamp);
// index name format: cwl-YYYY.MM.DD
var indexName = [
'cwl-' + timestamp.getUTCFullYear(), // year
('0' + (timestamp.getUTCMonth() + 1)).slice(-2), // month
('0' + timestamp.getUTCDate()).slice(-2) // day
].join('.');
#!/bin/bash
if [ $# -ne 3 ]; then
echo "Usage: $0 [AlarmName] [Region] [Profile]"
echo "Region: ap-northeast-1 ap-southeast-1 ap-southeast-2 eu-central-1 eu-west-1 sa-east-1 us-east-1 us-west-1 us-west-2"
exit
fi
NAME=$1
METRIC_NAME=StatusCheckFailed_System