Skip to content

Instantly share code, notes, and snippets.

@ideodora
ideodora / functions.php
Created November 21, 2014 18:11
WP JSON REST API の header 設定
# http://torquemag.io/preparing-wordpress-site-power-single-page-web-app/
add_filter( 'json_serve_request', function( ) {
$domains = array( 'http://torquemag.io', 'http://wordpress.org' );
if( isset( $_SERVER['HTTP_ORIGIN'] && in_array( $_SERVER['HTTP_ORIGIN'], $domain ) ) ) {
$domain = $_SERVER['HTTP_ORIGIN'];
header( "Access-Control-Allow-Origin: {$domain}" );
}
@ideodora
ideodora / gist:2b93494c9fe3c083fe35
Last active August 29, 2015 14:10
ajax no jquery browserify
var fetch = http.request({
host: "stackoverflow.com",
port: 80,
path: "/",
method: "GET",
withCredentials: false // this is the important part
}, function(res) {
var result = ""
res.on('data', function(chunk) {
result += chunk;
@ideodora
ideodora / gist:791d87ae3ebe627f4079
Created November 17, 2014 07:09
Urlfetch の param
from google.appengine.api import urlfetch
from urllib import urlencode
url = 'http://search.hatena.ne.jp/keyword’
params = {'mode' : 'rss',
'ie' : 'utf-8',
'word' : 'python',
'page' : 1}
@ideodora
ideodora / gist:c4cdc4c53d75fbd3b3e4
Created November 10, 2014 05:22
npm optimist って
http://d.hatena.ne.jp/sasaplus1/20120318/1332060348
@ideodora
ideodora / gist:ead4203df13383a29743
Created November 4, 2014 14:27
シェルスクリプト 変数展開 "${xxx+option}"
http://qiita.com/bsdhack/items/597eb7daee4a8b3276ba
@ideodora
ideodora / gist:0e6bc3c5a36a55759455
Last active August 29, 2015 14:08
shell ""(ダブルクオーテーション)''(シングルクオーテーション)``(バッククオーテーション)
# HOGE="pwd"として
echo "$HOGE"
#>> pwd
# 変数展開する
echo '$HOGE'
#>> $HOGE
@ideodora
ideodora / gist:c0b880bc8a09473252ed
Last active August 29, 2015 14:08
PARAMETER EXPANSION ${} 記法 置換
# ${} で変数展開する際に置換する?
#
# echo "${VAR/SEARCH/REPLACE}"
HOGE="abcdef"
echo $HOGE
#>> abcdef
echo "${HOGE/abc/xyz}"
http://blog.frd.mn/install-nginx-php-fpm-mysql-and-phpmyadmin-on-os-x-mavericks-using-homebrew/
@ideodora
ideodora / gist:932629af954abaafd795
Created October 14, 2014 07:13
Python プライベートメンバーへのアクセス
# プライベートメンバ変数にアクセス。
# インスタンス._クラス名__変数名でアクセスできる。(推奨されない)
print w._Widget__secret
@ideodora
ideodora / gist:a58d6fcbedb6dc7833c0
Created October 14, 2014 07:11
datetime から date への変換
# user date() method
datetime.datetime.now().date()