Skip to content

Instantly share code, notes, and snippets.

@wokamoto
wokamoto / config
Created September 4, 2012 01:27
SSH Proxy 用の .ssh/config 例
Host ssh_proxy
HostName ssh_proxy.example.net
Port 22
User hoge
IdentityFile ~/.ssh/id_rsa
Host target
HostName target.example.net
Port 22
User fuga
@wokamoto
wokamoto / replace-siteurl.php
Created September 4, 2012 23:22
WordPress のDB上のサイトURLを一気に変換
#!/usr/bin/php
<?php
switch($argc) {
case 1:
case 2:
echo "please input new site url and wp directory name!\n";
exit();
default:
$old_site = isset($argv[3]) ? $argv[3] : '';
$path = $argv[2];
@wokamoto
wokamoto / header-sample.php
Created September 6, 2012 07:10
[WordPress] style.css にバージョン番号を指定する
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>?ver=<?php echo date('YmdHis', filemtime(get_stylesheet_directory() . '/style.css')); ?>" />
@wokamoto
wokamoto / functions-sample.php
Created September 6, 2012 07:11
[WordPress] wp_enqueue_script で自動的にバージョン番号を変更する
wp_enqueue_script(
'example_js',
get_stylesheet_directory_uri() . '/js/example.js' ,
array() ,
date('YmdHis', filemtime(get_stylesheet_directory() . '/js/example.js'))
);
@wokamoto
wokamoto / default.conf
Created September 6, 2012 10:29
だれかさんへ(1)
server {
listen 80 default;
server_name _;
root /path/to/wordpress;
index index.html index.htm;
charset utf-8;
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log;
@wokamoto
wokamoto / relative_url.php
Created September 19, 2012 08:04
書き換える奴
class relative_URI {
private $top_url;
public function __construct() {
add_action('get_header', array(&$this, 'get_header'), 1);
add_action('wp_footer', array(&$this, 'wp_footer'), 99999);
$home_url = trailingslashit(get_home_url('/'));
$this->top_url = preg_replace( '/^(https?:\/\/.+?)\/(.*)$/', '$1', $home_url );
}
protected function replace_relative_URI($content) {
$pattern = '#(<[^>]+)(' . $this->top_url . ')#i';
@wokamoto
wokamoto / example.com.conf
Created October 4, 2012 15:50
網元用 サブドメイン型マルチサイト WP nginx 設定例
server {
listen 80;
server_name example.com *.example.com;
root /var/www/vhosts/example.com;
index index.html index.htm;
charset utf-8;
access_log /var/log/nginx/example.com.access.log main;
error_log /var/log/nginx/example.com.error.log;
@wokamoto
wokamoto / example.com.backend.conf
Created October 4, 2012 15:51
網元用 サブドメイン型マルチサイト WP nginx 設定例 (backend.conf)
server {
listen unix:/var/run/nginx-backend.sock;
server_name example.com *.example.com;
root /var/www/vhosts/example.com;
index index.php index.html index.htm;
access_log /var/log/nginx/example.com.backend.access.log backend;
keepalive_timeout 25;
port_in_redirect off;
@wokamoto
wokamoto / amimoto-update.sh
Created October 5, 2012 04:03
網元をアップデートする奴
#!/bin/sh
INSTANCEID=`/usr/bin/curl -s http://169.254.169.254/latest/meta-data/instance-id`
PUBLICNAME=`/usr/bin/curl -s http://169.254.169.254/latest/meta-data/public-hostname`
AZ=`/usr/bin/curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone/`
if [ "$AZ" = "eu-west-1a" -o "$AZ" = "eu-west-1b" -o "$AZ" = "eu-west-1c" ]; then
REGION=eu-west-1
TZ=WET
elif [ "$AZ" = "sa-east-1a" -o "$AZ" = "sa-east-1b" ]; then
REGION=sa-east-1
@wokamoto
wokamoto / amimoto-install.sh
Created October 29, 2012 06:17
Amimoto Anywhere!
#!/bin/sh
yum install -y git
cd /tmp/
/usr/bin/git clone git://github.com/megumiteam/amimoto.git
if [ -f /tmp/amimoto/initial ]; then
cd /tmp/amimoto
/bin/sh /tmp/amimoto/initial
fi
/bin/rm -Rf /tmp/amimoto