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 / 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 / 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 / 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 / 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 [email protected]:$1/$2.git
cd $2
@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 / backlog-deploy.php
Last active August 23, 2017 04:26
BacklogのWebフックを受け取って、テーマをビルドする
<?php
// パスを設定。なぜかこれがないと動かず。
putenv('PATH=/home/ec2-user/.nvm/versions/node/v6.11.0/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin');
//リリースするブランチの指定
$deploy_ref = 'refs/heads/master';
//logファイルの指定
$log_path = '/var/www/wordpress/wp-content/git.log';
@fumikito
fumikito / fb-message-parse.php
Created August 25, 2017 15:18
Parse facebook message from archived data
<?php
# composer require sunra/php-simple-html-dom-parser
require __DIR__ . '/vendor/autoload.php';
// Change file size because fb message archive is very big data.
define( 'MAX_FILE_SIZE', 1000000000 );
$dom = Sunra\PhpSimple\HtmlDomParser::file_get_html( 'messages.htm' );
$messages = [];
@fumikito
fumikito / backup-wp.sh
Created February 2, 2018 06:15
Backup statics of WordPress
#
# Backup WordPress contents.
#
set -e
# Move to WordPress dir
cd /var/www/wordpress
# Remove if exists.
@fumikito
fumikito / short-code-template.php
Created February 3, 2018 16:44
Template file shortcode
<?php
/**
* Register shortcode [my-template]
*
* File based short code.
*
* @param array $atts Shoutcode attribures.
* @param string $string Content wrapped in shortcode.
* @return string Rendered result.
*/
@fumikito
fumikito / hide_from_media_library.php
Created April 16, 2018 08:09
Hide specific attachments from media library.
<?php
/**
* Hide specific media from media library.
*/
/**
* Case 1. Do not allow gif.
*
* This filter will be triggered by media library's AJAX action.
*