Skip to content

Instantly share code, notes, and snippets.

@b0n
b0n / gist:3837285
Created October 5, 2012 00:18
コマンドで実行されたPHPでユーザー入力を待つ方法
<?php
/**
* @see http://www.php.net/manual/en/features.commandline.io-streams.php
*/
$input = fgets(STDIN,4096);
@b0n
b0n / gist:3838250
Created October 5, 2012 05:26
wordpressで管理画面のパスワード変更欄を非表示に
<?php
add_filter('show_password_fields', create_function('$a', "return false;"));
@b0n
b0n / gist:3842865
Created October 5, 2012 22:35
簡単!たった10行のコードでHTML取得&解析をするPHPスクリプト
<?php
$url = 'http://www.yahoo.co.jp';
$user_agent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)";
$opts = array(
'http' => array(
'method' => 'GET',
'user_agent' => $user_agent,
));
$context = stream_context_create($opts);
@b0n
b0n / gist:5675842
Created May 30, 2013 05:13
wordpress wp_get_archives で指定した月だけ取得する
/**
* 月を指定してwp_get_archivesを呼び出します
* @see common-sidebar.php
* @see wp-includes/general-template.php wp_get_archives()
*/
if ( ! function_exists( 'my_custom_post_type_archive_where' ) ) {
function my_custom_post_type_archive_where( $where, $args ){
if ($args['type'] != 'monthly')
return $where;
@b0n
b0n / gist:8556330
Created January 22, 2014 10:11
Movabletypeで検索系のcgi動作時に処理を回避する
<mt:setvarblock name="relation_parts"><mt:blogsitepath><$MTEntryDate format="%Y/%m"$>/<mt:entrybasename extension="0" separator="-">_rel.html</mt:setvarblock>
<mt:var name="search" value="0">
<mt:ifstraightsearch><mt:var name="search" value="1"></mt:ifstraightsearch>
<mt:iftagsearch><mt:var name="search" value="1"></mt:iftagsearch>
<mt:if name="search" eq="0">
<?php
ini_set('display_errors', false);
$file = '';
$file = "<mt:getvar name="relation_parts">";
echo "<!--" . $file . "-->";
#!/opt/local/bin/python2.7
import os
import shutil
f = open('cp.sh', 'r')
for line in f:
f = line.rstrip("\n")
d = "2014060302/" + os.path.dirname(line)
print f
#print d
shutil.copy(f, d)
@b0n
b0n / gist:c438dd80b597dcd1254d
Last active August 29, 2015 14:06
Select plugin name and version from wp page or plugins
# coding: utf-8
require 'open-uri'
require 'nokogiri'
url = "http://test.localhost/abc.plugin.html"
charset = nil
html = open(url) do |f|
charset = f.charset
f.read
@b0n
b0n / function.ssi.php
Last active August 29, 2015 14:14
smartyからssi呼び出し。テンプレと出力が異文字コード。 ref: http://qiita.com/mrk461/items/016822ebf827f8b7b31e
<?php
/**
* ssi
*/
function smarty_function_ssi($params, &$smarty)
{
if (empty($params['file'])) return '';
if (empty($params['ssi_enc'])) return '';
@b0n
b0n / gist:85c73f038f3258fc5e42
Created April 14, 2015 04:43
get subquery at cakephp
$query = $this->Post->getQuery('all', array(
'conditions' => array('Post.id' => array(1,2,3,4,5),
'fields' => array('Post.id'),
));
@b0n
b0n / gist:679862820d7870b9a11d
Created November 12, 2015 08:19
Checkbox family checked each other between parent and childrens.
$(function() {
$("#search > div > div.box.f-left > ul > li > input.genre").each(function() {
$(this).prop('checked', true);
if (!$(this).next().next().find('input:checkbox').prop('checked')) {
$(this).prop('checked', false);
}
});
$("#search > div > div.box.f-left > ul > li > input.genre").bind('change', function() {
$(this).next().next().find('input:checkbox').prop('checked', this.checked);
});