telnet www.example.com 80
curl -v www.example.com
GET / HTTP/1.1
WITH RECURSIVE results(id, i, picked, roll) AS ( | |
WITH bounds AS (SELECT min(id), max(id) - min(id) AS delta FROM table) | |
( | |
SELECT NULL::integer | |
, 0 | |
, ARRAY[]::integer[] | |
, min + round(delta * random()) | |
FROM bounds | |
) | |
UNION ALL |
在 [RubyConf.TW 2011][],我介紹了 [rest-core][],是用 Ruby 寫成的模組化 REST client 組合包與工具組。後來組合包的東西被抽至 [rest-more][],於是變成給 REST APIs 使用的模組化 Ruby clients interface。
在 [RubyConf.TW 2012][],我介紹了 Ruby 上的 concurrent 應用程式伺服器。之後在 rest-core 內,加入我從以上所學到的東西,使它能輕易地發出 concurrent requests。
在不同的使用情況下,我們有時候需要使用 promise、有時候需要使用 callback。這次我將介紹該怎麼利用 promise 來達成以我們所熟習的同步風格,發出
require 'rest-core' | |
module RestCore | |
middleware = Class.new | |
middleware.module_eval do | |
def initialize app | |
@app = app | |
end | |
def call env, &k |
13:15 <xQuasar> | HASKELL IS FOR FUCKIN FAGGOTS. YOU'RE ALL A BUNCH OF | |
| FUCKIN PUSSIES | |
13:15 <xQuasar> | JAVASCRIPT FOR LIFE FAGS | |
13:16 <luite> | hello | |
13:16 <ChongLi> | somebody has a mental illness! | |
13:16 <merijn> | Wow...I suddenly see the error of my ways and feel | |
| compelled to write Node.js! | |
13:16 <genisage> | hi | |
13:16 <luite> | you might be pleased to learn that you can compile | |
| haskell to javascript now |
$stack, $draws = [], {} | |
def method_missing *args | |
return if args[0][/^to_/] | |
$stack << args.map { |a| a or $stack.pop } | |
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :< | |
end | |
class Array | |
def +@ |