Skip to content

Instantly share code, notes, and snippets.

View fumikito's full-sized avatar
🐕
Have 1 dog. Her name is Packing.

Takahashi Fumiki fumikito

🐕
Have 1 dog. Her name is Packing.
View GitHub Profile
@fumikito
fumikito / punctuate.php
Last active July 4, 2017 08:51
WordPressからlet's punctuateを利用するgist
<?php
/**
* Tokenize string to morphemes.
*
* @param string $string
* @return array
*/
function hametuha_punctuate( $string ) {
try {
@fumikito
fumikito / deploy-plugin
Last active June 2, 2017 04:37
deploy-plugin
#! /usr/bin/env bash
set -e
echo "Compiling $1/$2..."
cd ~/Downloads
mkdir tmp
cd tmp
git clone git@github.com:$1/$2.git
cd $2
@fumikito
fumikito / request.php
Created March 2, 2017 08:07
A typical jQuery request to WordPress REST API
<?php
/**
* Regsiter script
*/
add_action( 'wp_enqueue_scripts', function() {
// Set dependency to wp-api, which has nonce and endpoint root.
wp_enqueue_script( 'api-handler', '/path/to/api-handler.js', [ 'jquery', 'wp-adpi' ], '1.0', true );
} );
@fumikito
fumikito / result.json
Created July 21, 2016 05:07
https://hametuha.com/news/article/16685/ この記事を Google Natural Language API のtextEntities にかけてみた
{
"entities": [
{
"name": "村田沙耶香",
"type": "PERSON",
"metadata": {
"wikipedia_url": "http://ja.wikipedia.org/wiki/%E6%9D%91%E7%94%B0%E6%B2%99%E8%80%B6%E9%A6%99"
},
"salience": 0,
"mentions": [
@fumikito
fumikito / list.php
Last active May 15, 2016 14:34
ゲンロンSF講座2016の実作提出者リストを取得する
<?php
/**
* ゲンロンSF講座の落選者実作を取得する
*
* simple_html_dom.phpをダウンロードして、同じフォルダに置いてください。
* https://sourceforge.net/projects/simplehtmldom/files/
*
* @example
* php list.php http://school.genron.co.jp/works/sf/2016/subjects/definition/
*/
@fumikito
fumikito / endpoint.php
Last active March 25, 2016 10:26
エンドポイント
<?php
//
// ここから書いていく
//
add_action( 'rest_api_init', function(){
register_rest_route( 'tweeter/v1', '/friends/(?P<user_id>[0-9]+)/?', [
[
'methods' => 'POST',
'callback' => function($params){
@fumikito
fumikito / login.php
Last active March 23, 2016 15:21
勝手にログイン
<?php
# ID1でログインする
include __DIR__.'/wp-load.php';
wp_set_auth_cookie(1);
header( 'Location: '.admin_url() );
exit;
@fumikito
fumikito / change_user_meta.sql
Created March 21, 2016 08:30
間違ってたクエリを直す
update tweeter_usermeta set meta_key = 'tweeter_capabilities' where meta_key = 'wp_capabilities';
update tweeter_options set option_name = 'tweeter_user_roles' where option_name = 'wp_user_roles';
@fumikito
fumikito / pages-input.applescript
Created January 27, 2016 02:13
Interactive Pages input
on run {input, parameters}
tell application "Pages"
activate
open input
tell front document
-- GET ALL TAGS
set theseTags to the tag of every placeholder text
-- FILTER FOR UNIQUE TAGS
@fumikito
fumikito / get_template_part.php
Created December 21, 2015 03:59
Alternative of WordPress' get_template_part which can accept arguments.
<?php
/**
* A template loader which accepts arguments.
*
* @param string $slug
* @param string|array $name
* @param array $args Arguments to pass.
* @param bool $echo If false, return string.
* @param string $glue Default is '-'. You can specify '/' which means directory separator.
*