Skip to content

Instantly share code, notes, and snippets.

View chihirokaasan's full-sized avatar

ChihiroMazda chihirokaasan

View GitHub Profile
@chihirokaasan
chihirokaasan / functions.php
Created February 10, 2016 06:09
WordPressのカスタムプロフィールを一番下に挿入する
function custom_user_profile( $user ) {
//以下カスタムプロフィールの追加フォーム
?>
<table id="custom_user_field_table" class="form-table">
<tr id="custom_user_field_row">
<th>
<!--項目名-->
<label for="custom_field"><?php _e('Field'); ?></label>
</th>
<td><!--追加のフォームはここ-->
add_filter('manage_media_columns', 'columns_head');
add_filter('manage_media_custom_column', 'columns_content', 10, 2);
@chihirokaasan
chihirokaasan / mod_evasiveの設定
Created February 18, 2016 01:06
/etc/httpd/conf.d/mod_evasive.conf
LoadModule evasive20_module modules/mod_evasive20.so
<IfModule mod_evasive20.c>
DOSHashTableSize 3097
#1秒間に何回同じページにアクセスされたら
DOSPageCount 5
#1秒間に何回サイトにアクセスされたら
DOSSiteCount 30
#1秒間でのページアクセス
DOSPageInterval 1
#1秒間でのサイトアクセス
@chihirokaasan
chihirokaasan / functions.php
Created February 19, 2016 13:02
Add original jQuery script to WordPress admin page.
function my_jquery($hook) {
if($hook == 'edit.php'){
wp_enqueue_script('custom_admin_script', get_bloginfo('template_url').'/js/my_jquery.js', array('jquery'));
}
}
add_action('admin_enqueue_scripts', 'my_jquery');
//jQueryでない場合、 wp_enqueue_scriptの第三引数は不要です。
@chihirokaasan
chihirokaasan / functions.php
Created February 19, 2016 13:28
Add the jQuery only when the custom post type
function my_jquery($hook) {
if($hook == 'edit.php'){
global $post;
if ( $hook == 'post-new.php' || $hook == 'post.php' ) {
if ( 'custom_post_name' === $post->post_type ) {
wp_enqueue_script('custom_admin_script', get_bloginfo('template_url').'/js/my_jquery.js', array('jquery'));
}
}
}
}
@chihirokaasan
chihirokaasan / Counter.php
Created March 2, 2016 03:59
php mongo seq
<?php
//cakephpチックに書くとこんな感じ?
//cakephpでなければ適当にfunctions のところだけ抜き出して使ってください
App::uses('AppModel', 'Model');
class Counter extends AppModel {
public function connect() {
$client = new MongoClient();
$db = $client->selectDB('databaseName');
return $db;
}
@chihirokaasan
chihirokaasan / insertNew.php
Created March 2, 2016 04:13
Insert mongo with AutoIncrement
$itemid = $this->Counter->seq('itemid');
$itemArray = [ "_id" => $itemid['value']['seq'],
"title" => 'hogehoge',
"user_id" => 1,
"created" => date('Y-m-d H:i:j'),
];
function add($itemArray) {
$client = new MongoClient();
$db = $client->selectDB('databaseName');
@chihirokaasan
chihirokaasan / mongodb.repo
Created March 15, 2016 00:52
mongo3.2のリポジトリ作成
[mongodb-org-3.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/
gpgcheck=0
enabled=1
@chihirokaasan
chihirokaasan / LAMP+MongoDB3.2 PHP5.6 MySQL5.6環境構築手順
Last active March 15, 2016 01:12
CentOS7 LAMP+MongoDB3.2環境構築
● MongoDBインストール
yum install mongodb-org
●自働起動
chkconfig mongod on
●epelリポジトリ
yum install -y epel-release
●wget インストチェック
@chihirokaasan
chihirokaasan / Vagrantfile
Last active July 20, 2016 04:39
CentOS7のVagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at