Skip to content

Instantly share code, notes, and snippets.

View godfat's full-sized avatar

Lin Jen-Shin (godfat) godfat

View GitHub Profile
@godfat
godfat / draft.md
Last active August 29, 2015 14:10
The Promise of rest-core

rest-core 的承諾

在 [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 來達成以我們所熟習的同步風格,發出

@godfat
godfat / query.sql
Last active August 29, 2015 14:22
PostgreSQL fast random rows for tables with integer id with uniform distribution
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
require 'rest-core'
module RestCore
middleware = Class.new
middleware.module_eval do
def initialize app
@app = app
end
def call env, &k
@godfat
godfat / gw2-builds.md
Last active March 19, 2018 06:33
GW2 builds

Professions

Elementalist

  • TBA

Mesmer

  • [wvw group boon share chronomancer][]
  • [wvw roaming hybrid mirage][]
@godfat
godfat / cats-rank.md
Last active April 26, 2019 08:14
The Battle Cats - Cats rank

Top (Powerful for most of the stages, and no alternatives at all)

  1. Miko Mitama (Uberfest)
  2. Kasa Jizo (Ultra Souls)
  3. Radiant Aphrodite (Almighties)

5 stars (Powerful for most of the stages, but could be replaced with specific cats)

  • D'artanyan (Uberfest)
  • D'arktanyan (Epicfest)

HTTP

Connection

telnet www.example.com 80
curl -v www.example.com

Request

GET / HTTP/1.1
@andkerosine
andkerosine / raskell.rb
Created August 15, 2012 05:56
Haskell-like list comprehensions in Ruby
$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 +@
@quchen
quchen / trolling_haskell
Last active November 12, 2024 00:10
Trolling #haskell
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