[enhance] oktest.web.WSGITestクラスが、マルチパート形式をサポート ex:
## マルチパート形式のデータを作成 from oktest.web import MultiPart mp = MultiPart() # or boundary='abcdef'; mp = MutliPart(boundary) mp.add("name1", "value1") # add string value with open("logo.png", 'wb') as f: # add file value mp.add("file1", f.read(), "logo.png", "image/png") ## マルチパートデータを指定してリクエストを投げる
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 -*- | |
## | |
## latest version of twitter-bootstrap is expected as 3.2.0 but got 3.1.1 with API. | |
## | |
require 'open-uri' | |
require 'json' | |
libname = 'twitter-bootstrap' |
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 'open-uri' | |
require 'fileutils' | |
require 'json' | |
CDNJS_URL = "http://api.cdnjs.com/libraries?search={keyword}&fields=assets" | |
# | |
libname = 'angular.js' |
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
from datetime import datetime | |
class Foo(datetime): | |
def __init__(self): | |
datetime.__init__(self, 2014, 7, 1, 0, 0, 0) | |
obj = Foo() | |
### result: | |
# |
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
-- | |
-- 要件:条件に一致するレコードが1件もない場合は、デフォルト値として 0 を使いたい | |
-- | |
-- 実験1: 通常は、条件に一致するレコードが1件もない場合は 0 rows になる | |
psql=> select point::integer | |
from user_point_history | |
where user_id = 12595 and created_at > '2014-06-01'; | |
point |
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
## たとえば history.txt の内容がこういう履歴になっていたとして、 | |
bcgf7647 # [john] create 'users' table | |
fdon4243 # [john] add 'birthday' column | |
## alice が 2 件のマイグレーションを追加したとします | |
bcgf7647 # [john] create 'users' table | |
fdon4243 # [john] add 'birthday' column | |
ycii2472 # [alice] change 'birthday' column as not-null |
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
### Pythonのtestモジュールを消すと、ファイル容量が28MB減った | |
$ du -sk python/2.7.7 | |
95664 python/2.7.7 | |
$ du -sk python/2.7.7/lib/python2.7/test | |
28412 python/2.7.7/lib/python2.7/test | |
$ rm -rf python/2.7.7/lib/python2.7/test/[a-zA-Z1-9]* | |
$ du -sk python/2.7.7 | |
67264 python/2.7.7 | |
$ ruby -e 'p 95664-67264' | |
28400 |
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
from sqlalchemy import func | |
from sqlalchemy.types import UserDefinedType, Float | |
class EasyGeometry(UserDefinedType): | |
def get_col_spec(self): | |
return "GEOMETRY" | |
def bind_expression(self, bindvalue): |
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
/* ref: http://lets.postgresql.jp/documents/technical/9.1/1 */ | |
create table members ( | |
id serial primary key | |
, name varchar(255) not null unique | |
, gender char(1) not null -- 'F': female, 'M': male | |
, role varchar(255) | |
); | |
-- Run 'update' statement, or run 'insert' statement when failed. |
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
-- I want to rename column1 and column2 into id and name | |
psql=> values (101, 'Steve'), (102, 'Bill'); | |
column1 | column2 | |
---------+--------- | |
101 | Steve | |
102 | Bill | |
(2 rows) |