Skip to content

Instantly share code, notes, and snippets.

@marucc
marucc / jq_tmpl.py
Created February 26, 2015 07:22
Djangoのテンプレートシンタックスとかち合わないようにjQuery Templatesを使った場合に作ったテンプレートプラグイン。 templatetags以下に置く。 Djangoのテンプレートhtml内で {% load jq_tmpl %} して使う
# -*- coding: utf-8 -*-
from django import template
register = template.Library()
class JqTagNode(template.Node):
@marucc
marucc / example.html
Created February 24, 2015 06:51
KnockoutJSで、Validation通した値でcssの変更を行いたい場合のサンプル
<!DOCTYPE html>
<title>sample</title>
<style>.error { color:red }</style>
<div id="main">
<input type="text" data-bind="value: name, valueUpdate: 'afterkeydown'">
<span data-bind="css: { error: is_error }">*required</span>
<hr>
Name: <span data-bind="text: name"></span>
</div>
@marucc
marucc / html5_validator.py
Last active December 18, 2015 23:49
html5のチェック html5libを入れている環境でworkonしておくこと。
#!/usr/bin/env python
# coding: utf-8
import os
import sys
from html5lib import HTMLParser
argvs = sys.argv
argc = len(argvs)
@marucc
marucc / getAge.php
Created March 3, 2012 04:18
getAgeFromBirthday for php
<?php
// floor((Ymd - Ymd)/10000)
// 月齢、日にちまで求めないならこれで十分
function getAge($birthday, $today)
{
return (int)floor(((int)$today-(int)$birthday)/10000);
}
// test