Skip to content

Instantly share code, notes, and snippets.

@wokamoto
wokamoto / fc2blog.conf
Last active August 29, 2015 13:57
[Nginx] fc2blog 用
upstream phpfpm {
server localhost:9000;
}
server {
listen 80;
server_name _;
root /var/www/html;
index index.php index.html index.htm;
@wokamoto
wokamoto / gist:9800905
Created March 27, 2014 05:26
[WordPress] remote_get transient
<?php
function transient_remote_get($url, $expiration = 3600) {
$transient = 'remote_get-' . md5($url);
if ( ! ($response_body = get_transient($transient)) ) {
$response = wp_remote_get($url);
if( !is_wp_error($response) && $response["response"]["code"] === 200 ) {
$response_body = $response["body"];
set_transient($transient, $response_body, $expiration);
} else {
$response_body = false;
@wokamoto
wokamoto / gist:9825777
Created March 28, 2014 05:07
MySQL 5.5 → 5.6 にアップデートした後に mysql データベースに作っておくテーブルを作成するための SQL
CREATE TABLE `innodb_table_stats` (
`database_name` varchar(64) COLLATE utf8_bin NOT NULL,
`table_name` varchar(64) COLLATE utf8_bin NOT NULL,
`last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`n_rows` bigint(20) unsigned NOT NULL,
`clustered_index_size` bigint(20) unsigned NOT NULL,
`sum_of_other_index_sizes` bigint(20) unsigned NOT NULL,
PRIMARY KEY (`database_name`,`table_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0;
@wokamoto
wokamoto / clear.sh
Last active August 29, 2015 13:57
[AWS] AMI 作る前に最低限やっておくこと
#!/bin/sh
rm -rf /tmp/*
rm -f /etc/ssh/ssh_host_*
if [ -d /var/log ]; then
find /var/log -type f -print | xargs -L1 /bin/cp /dev/null
fi
if [ -d /var/spool/mail ]; then
find /var/spool/mail -type f -print | xargs -L1 /bin/cp /dev/null
fi
@wokamoto
wokamoto / gist:11365599
Last active August 29, 2015 14:00
にしかわさんへ
<?php
add_filter('the_content', 'my_shortcode', 7);
function my_shortcode( $content ) {
global $shortcode_tags;
$shortcode_tags_org = $shortcode_tags;
remove_all_shortcodes();
add_shortcode('code', 'my_shortcode_handler');
$content = do_shortcode( $content );
msgid ""
msgstr ""
"Project-Id-Version: my-plugin\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
"Last-Translator: Your Name Here <Your E-Mail Here>\n"
"Language-Team: JAPANESE <http://wppluginsj.sourceforge.jp/>\n"
"Language: ja_JP\n"
"MIME-Version: 1.0\n"
@wokamoto
wokamoto / gist:11389543
Created April 29, 2014 02:43
[WordPress] API プラグインスケルトン
<?php
/*
Plugin Name: My API
Version: 0.1-alpha
Description: 記事取得用 API
Author: wokamoto@digitalcube
Author URI: https://digitalcube.jp
Plugin URI: https://digitalcube.jp
Text Domain: my-api
Domain Path: /languages
@wokamoto
wokamoto / fetch_feed_wrapper.php
Created May 21, 2014 03:59
[WordPress] fetch_feed_wrapper
<?php
if ( !function_exists('fetch_feed') )
include_once(ABSPATH . WPINC . "/feed.php");
if ( !class_exists('fetch_feed_wrapper') ):
class fetch_feed_wrapper {
private $feed;
private $current = 0;
@wokamoto
wokamoto / wckansai_2014.md
Last active August 29, 2015 14:02
WordCamp Kansai 資料(素案)

WordPress サーバ運用

最小構成

Web サーバを Apache から Nginx に

画像ファイルを外出し

CDN の導入

  • Cloudflare
@wokamoto
wokamoto / patch.txt
Created July 1, 2014 01:55
[WordPress] bogo ver.2.2 nginx rearite 対応パッチ
--- includes/rewrite.php.org 2014-07-01 10:51:03.000000000 +0900
+++ includes/rewrite.php 2014-07-01 10:51:50.000000000 +0900
@@ -38,7 +38,7 @@
$permastruct = $wp_rewrite->permalink_structure;
- if ( ! apache_mod_loaded( 'mod_rewrite', true ) && ! iis7_supports_permalinks() )
+ if ( ! got_url_rewrite() )
$permastruct = preg_replace( '#^/index\.php#', '/index.php/%lang%', $permastruct );
elseif ( is_multisite() && ! is_subdomain_install() && is_main_site() )