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
$ python rpentomino.py 1 | |
○○ | |
○○ | |
○ | |
$ python rpentomino.py 2 | |
○○○○ | |
○○○○ | |
○○○○ | |
○○○○ | |
○○ |
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 -tt | |
# -*- coding: utf-8 -*- | |
daglike = ['シュークリーム'] | |
daghate = ['Flask', 'Django'] | |
def main(): | |
m = 0 | |
while True: |
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 thread | |
from django.conf import settings | |
from django.core.context_processors import csrf | |
from django.http import HttpRequest, HttpResponse | |
from django.middleware.csrf i |
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
{ | |
"secret_key": | |
"akismet_api_key": | |
"db_default_user": | |
"db_default_password": | |
"db_default_host": | |
"db_default_port": | |
} |
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 django import forms | |
from django.forms import widgets | |
from django.utils.translation import ugettext_lazy | |
from django.utils.encoding import force_unicode | |
from django.utils.html import escape, conditional_escape | |
from django.utils.safestring import mark_safe | |
class InlineRadioInput(widgets.RadioInput): | |
def render(self, name=None, value=None, attrs=None, choices=()): | |
name = name or self.name |
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 django.http import HttpResponseRedirect | |
from django.views.generic.base import TemplateResponseMixin, View | |
class ParamMixin(object): | |
failed_url = None | |
allowed_params = None | |
def get_failed_url(self): | |
return self.failed_url |
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 django.views.generic import View | |
from django.http.response import HttpResponse | |
def corn_predicate(request): | |
params = getattr(request, request.method) | |
corn = params.get('corn', None) | |
return corn == u'1' | |
class PonyView(View): |
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 django.views.generic import View | |
from django.http.response import HttpResponse | |
class RequestParamPredicate(object): | |
def __init__(self, val): | |
k = val | |
v = None | |
if '=' in val: | |
k, v = val.split('=', 1) | |
k, v = k.strip(), v.strip() |
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 -*- | |
from sqlalchemy import ( | |
create_engine, | |
Table, | |
Column, | |
Integer, | |
String, | |
MetaData, | |
ForeignKey, |
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 urllib import urlencode | |
from django.template import Library | |
register = Library() | |
@register.filter(name='query_string' | |
def query_string(value, arg): | |
""" | |
Takes QueryDict's instance and argument. |
OlderNewer