This file contains hidden or 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
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>15 Puzzle</title> | |
<link rel="stylesheet" type="text/css" href="main.css" /> | |
</head> | |
<body> | |
<div id="main-content"> | |
<table id="puzzle"> | |
<tbody> |
This file contains hidden or 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 -*- | |
### | |
### Benchmark: http://cocodrips.hateblo.jp/entry/2015/10/11/114212#問題2 | |
### | |
from benchmarker import Benchmarker | |
try: | |
xrange |
This file contains hidden or 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 -*- | |
### | |
### Benchmark: create a list object padding by zero | |
### | |
from benchmarker import Benchmarker | |
try: | |
xrange |
This file contains hidden or 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 -*- | |
require 'sinatra/base' | |
require 'rack' | |
require 'rack/protection' | |
require 'rack/protection/frame_options' | |
require 'rack/protection/http_origin' | |
require 'rack/protection/ip_spoofing' | |
require 'rack/protection/json_csrf' | |
require 'rack/protection/path_traversal' |
This file contains hidden or 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
@on('POST', '/foobar') | |
def do_post(self): | |
do_something1() | |
do_something2() | |
## 残念ながら Python ではブロックをスキップする機能が | |
## ないのでこれは使えない | |
with invoke('new_cool_feature_name'): | |
old_feature1() | |
old_feature2() | |
## なので、decoratorをhiger order functionの |
This file contains hidden or 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 os.path import getmtime | |
class TemplateError(Exception): |
This file contains hidden or 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 -*- | |
/// | |
/// very small DOM builder using wabi-sabi style | |
/// | |
/// Example: | |
/// | |
/// var a = dom(["a", {href: "/link"}, "Link"]); | |
/// console.log(a); | |
/// //=> <a href="/link">Link</a> |
This file contains hidden or 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
## | |
## SQLAlchemyで、条件を動的に追加するときの書き方 | |
## | |
## | |
## before | |
## | |
q = db.query(Model) \ | |
.filter(Model.created_at >= date(2015, 6, 1) | |
if kind: |
This file contains hidden or 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 -*- | |
import re, random | |
from sqlalchemy.exc import IntegrityError | |
from smapo.common.models.event import EventOperation | |
from smapo.common.models.base import ( | |
DBSession, RedirectPage, RedirectUniqueCode, UserActionHistory, | |
) |
This file contains hidden or 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 -*- | |
import sys | |
try: | |
xrange | |
except NameError: | |
xrange = range | |