Skip to content

Instantly share code, notes, and snippets.

@ahomu
ahomu / gist:975807
Created May 17, 2011 02:50
[a-blog cms] メール本文をtouch
<!-- メール送信系フォーム内と仮定 -->
<select name="choice">
<option value="あー"{choice:selected#あー}>あー</option>
<option value="いー"{choice:selected#いー}>いー</option>
<option value="うー"{choice:selected#うー}>うー</option>
</select>
<input type="hidden" name="field[]" value="choice" />
@ahomu
ahomu / gist:1075711
Created July 11, 2011 11:52
[a-blog cms] 特定カテゴリーの祖先をたどる
$cid = 10; // 任意のcid
$DB = DB::singleton(dsn());
$SQL = SQL::newSelect('category');
$SQL->addSelect('category_id');
$SQL->addSelect('category_name');
$SQL->addSelect('category_code');
ACMS_Filter::categoryTree($SQL, $cid, 'ancestor');
$SQL->addOrder('category_left', 'ASC');
$all = $DB->query($SQL->get(dsn()), 'all');
@ahomu
ahomu / JSONP.php
Created December 6, 2011 09:11
[a-blog cms] すごく適当にJSONPを作成するモジュール草稿
<?php
require_once ACMS_LIB_DIR.'GET.php';
class ACMS_GET_Util_JSONP extends ACMS_GET
{
function get()
{
return $this->Get->get('jsoncallback').'({html: '.json_encode($this->tpl).'});';
}
@ahomu
ahomu / util.form.data.js
Created December 26, 2011 05:19
フォームの入力値をobjectとして取得するよ
/**
* フォーム内の入力値をobjectとして取得する
*
* @param {Node} form
* @return {Object}
*/
function getFormData(form) {
if (form.tagName !== 'FORM') {
throw new TypeError('Argument must be HTMLFormElement.');
}
@ahomu
ahomu / gist:1520565
Created December 26, 2011 05:24
getElementsByClassNameの代替関数
function AdaptiveGetElementsByClassName(clazz) {
var elems = this.getElementsByTagName('*'),
evClass = ' '+clazz+' ',
i = 0,
e = null,
rv = [];
while ( e = elems[i] ) {
if ( e.nodeType === Node.ELEMENT_NODE && (' '+e.className+' ').indexOf(evClass) !== -1 ) {
rv.push(e);
@ahomu
ahomu / gist:1604242
Created January 13, 2012 02:07
iが大事なとき
// hayate.js内の関数から改変
function toArrayCopy(list) {
var rv= new Array(list.length), i = 0, iz = list.length;
for (; i<iz; i++) {
rv[i]= list[i];
}
return rv;
}
@ahomu
ahomu / .gitconfig
Created February 2, 2012 11:17
[alias]
# pretty graph -> http://d.hatena.ne.jp/sugyan/20111103/1320247493
tr = log --graph --pretty='format:%C(yellow)%h%Creset %s %Cgreen(%an)%Creset %Cred%d%Creset'
# back correct
bc = commit --amend -m
# untracked files
ut = git ls-files -o --exclude-from=.gitignore
# stash
s = stash
sa = stash apply
@ahomu
ahomu / gist:2048971
Created March 16, 2012 07:09
jQuery(Sizzle)のバグ検証コード
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="ja" lang="ja" dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
var results = document.getElementById('results'),
exprCollection = [
':text', ':input', ':password', ':radio', 'checkbox',
@ahomu
ahomu / gist:2412035
Created April 18, 2012 08:23
ヾ('ω'ヾ) ごみ
// blinkメソッドを追加
jQuery.fn.extend({
blink: function (callback) {
var self = this;
self.fadeOut(500, function() {
self.fadeIn(200, function() {
callback && callback();
});
});
}
@ahomu
ahomu / gist:2766717
Created May 22, 2012 04:58
#ablogcms 無限に入ってもらっては困る系カスタムフィールドグループはこう書いたりしてる
<h3>サブナビゲーション</h3>
<table class="adminTable">
<tr>
<th></th>
<th>ラベル</th>
<th>リンク先</th>
</tr>
<tr>
<td>
1