Skip to content

Instantly share code, notes, and snippets.

@hykw
hykw / dblock.py
Last active August 29, 2015 14:21 — forked from atabary/dblock.py
#-*- coding: utf-8 -*-
import contextlib
from django.db import connection
@contextlib.contextmanager
def acquire_table_lock(read, write):
'''Acquire read & write locks on tables.
@hykw
hykw / main.js
Last active August 29, 2015 14:17 — forked from masuidrive/main.js
/**
* Google Spreadsheet向けBigQuery取り込みスクリプト
* http://toreta.blog.jp/archives/20649904.html
* License: MIT 2014- Toreta, Inc.
*
* runAllQueries() をトリガーで毎日実行してください
* Queries, Single row queries, Dataの三つのシートを作って下さい
* Queries, Single row queriesのシートには実行するクエリを書きます
* A列にクエリ名、B列にクエリです。
* conuntなどの集約関数で1行しか返らないクエリは「Single row queries」、それ以外は「Queries」に書いて下さい
@hykw
hykw / gist:158d4dc7d0419b771d77
Created October 21, 2014 01:38
htpassword の crypt 認証によるハッシュ生成
htpassword -d /tmp/passwd username
@hykw
hykw / gist:2051d82ef2ec76869e03
Last active August 29, 2015 14:06
svnのcopy, merge, switch方法
svn copy trunk branches/hogehoge
svn commit
→ リビジョン12345とする
# 〜〜〜 branchで作業、最終リビジョンは22222
# BASEディレクトリにcd(svn mergeはパスを指定しないと作業ディレクトリを対象にしちゃうので)
cd ~/svn/hogeSVN
# 12345〜22222(≒ HEAD)の修正を trunk にマージ
@hykw
hykw / gist:65fb50edf11edf1cd9bc
Created September 4, 2014 06:30
wordpress: nonce
$nonce = wp_nonce_field('pagename', '_wpnonce', true, false);
<form>
{$nonce}
</form>
---------------------
if(is_page('pagename') && isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'pagename')) {
#
} else {
@hykw
hykw / gist:a60acc3fbec3d55320c1
Created September 3, 2014 00:59
grep で tab 検索
grep $'\t'
@hykw
hykw / gist:bb0a1d034b648c275643
Last active August 29, 2015 14:04
MySQL: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='
/etc/my.cnf
-------------------------
default-character-set=utf8
character-set-server = utf8
collation-server=utf8_general_ci
init_connect='SET collation_database = utf8_general_ci; SET collation_connection = utf8_general_ci'
skip-character-set-client-handshake
-------------------------
mysql> ALTER DATABASE db CHARACTER SET utf8 COLLATE utf8_general_ci
@hykw
hykw / gist:3e43d3e62d34bb7e718e
Created July 18, 2014 09:54
wordpress: 投稿画面の項目非表示
function remove_default_post_screen_metaboxes() {
remove_meta_box( 'tagsdiv-post_tag' , 'post' , 'side' ); /* 投稿のタグ */
}
add_action('admin_menu','remove_default_post_screen_metaboxes');
@hykw
hykw / gist:27f9586f2e9af88afe56
Created July 18, 2014 09:44
wordpress: 投稿画面に注記を追加
function after_title() {
echo '<p>これはタイトル下に表示される</p>';
}
add_action( 'edit_form_after_title', 'after_title' );
function after_editor() {
echo '<p>これはエディタ下に表示される</p>';
}
add_action( 'edit_form_after_editor', 'after_editor' );
@hykw
hykw / gist:f62244c4fe1924ecfd6d
Last active August 29, 2015 14:04
wordpress: 固定ページでページング
■コンテンツ側
<!--nextpage-->
■php側
<?php
# ページングタグを表示する所で設定
wp_link_pages();
--------
c.f.