This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from json import dumps, loads | |
from UserDict import DictMixin | |
class JsonSerializedDict(DictMixin): | |
""" | |
>>> JSD = JsonSerializedDict | |
>>> d = JSD() | |
>>> print d | |
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, binascii | |
def get_secret_key(key_filename): | |
key_path = os.path.join(BASE_DIR, 'conf', key_filename) | |
if not os.path.exists(key_path): | |
try: | |
umask_saved = os.umask(0277) | |
with open(key_path, 'wb') as key_file: | |
key_file.write(binascii.b2a_base64(os.urandom(64)).rstrip('=')) | |
finally: | |
os.umask(umask_saved) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form id="delete_form" | |
method="POST" action="{% url 'delete_something' %}"> | |
{% csrf_token %} | |
<div> | |
<input type="hidden" name="delete" value=""> | |
<button id="delete_button" type="button">Delete</button> | |
<script> | |
$('#delete_button').on('click', | |
form_confirmation_factory('delete_form', | |
'Delete', 'Existing something will be removed.', 'OK', 'Cancel')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table> | |
{% for obj in page %} | |
<tr><td>{{ obj.blah }}</td></tr> | |
{% endfor %} | |
{% ifequal page.number page.paginator.num_pages %} | |
{% for padding in page.paginator.paddngs %} | |
<tr><td> </td></tr> | |
{% endfor %} | |
{% endifequal %} | |
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container padding10"> | |
<h1>Add user</h1> | |
<div class="padding10"> | |
<form method="POST" action="{% url 'user_add' %}"> | |
{% csrf_token %} | |
<fieldset> | |
{% with field=form.is_superuser type='switch' %}{% include "share/form_field.html" %}{% endwith %} | |
{% with field=form.is_active type='switch' %}{% include "share/form_field.html" %}{% endwith %} | |
{% with field=form.username type='text' %}{% include "share/form_field.html" %}{% endwith %} | |
{% with field=form.password type='password' %}{% include "share/form_field.html" %}{% endwith %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
"""外部DBMS | |
""" | |
import os | |
from functools import wraps | |
from json import loads | |
from logging import getLogger | |
from threading import local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
"""dataTables.js 用のクエリパーザ | |
""" | |
import re | |
class DataTablesQueryParser(object): | |
"""dataTables.js 用のクエリパーザ | |
""" | |
def __init__(self, request, column_map=dict(), method='POST'): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
class MatchContext(object): | |
""" | |
>>> import re | |
>>> with MatchContext(re.match(r'(.)', 'a')) as context: | |
... print context.groups() | |
('a',) | |
>>> import re | |
>>> with MatchContext(re.match(r'(.)', '')) as context: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// requires jquery-ui. | |
function closable_tab (tab_container_id, tab_config) { | |
// 閉じるボタン付きのタブコントロール | |
var tab_container = $(tab_container_id); | |
var tab_list = tab_container.find('ul'); | |
// タブ追加用のハンドラ | |
function _add_page (evt) { | |
console.log(evt); | |
var id = tab_config.get_id(evt.currentTarget); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding: utf-8 | |
"""Mimic legacy blast's blastall to execute BLAST+ commands | |
""" | |
import argparse, os, sys | |
def main(): | |
sys.stderr.write('>>>>> %s\n' %(' '.join(sys.argv))) | |
parser = argparse.ArgumentParser() | |
parser.add_argument('-p', dest='program', required=True) |
OlderNewer