[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
-- | |
-- 要件:条件に一致するレコードが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
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
# -*- 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
# -*- 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 'erb' | |
erb = ERB.new <<'END' | |
<html> | |
<body> | |
<ul> | |
<% (1..3).each do %> | |
<li><%= x %></li> |
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 'baby_erubis' | |
erb = BabyErubis::Html.new.from_str <<'END', __FILE__, __LINE__+1 | |
<html> | |
<body> | |
<ul> | |
<% (1..3).each do %> | |
<li><%= x %></li> |
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
-- | |
-- data | |
-- | |
psql=> select * from users; | |
id | name | |
----+------- | |
1 | Bob | |
2 | Alice | |
3 | John | |
(3 rows) |
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
~$ telnet cache.ruby-lang.org 80 | |
Trying 103.245.222.184... | |
Connected to fallback.global-ssl.fastly.net. | |
Escape character is '^]'. | |
GET /pub/ruby/ HTTP/1.0 | |
Host: cache.ruby-lang.org | |
HTTP/1.1 200 OK | |
Server: nginx/1.2.1 | |
Content-Type: text/html |
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: シーケンスを受け取り、N個ずつの配列にして返すような関数 each_slice(seq, n, default=None) を定義してください。 | |
例: | |
seq = [10, 20, 30, 40, 50, 60, 70] | |
for item in each_slice(seq, 3): | |
print(item) | |
## 結果: | |
[10, 20, 30] | |
[40, 50, 60] |