Skip to content

Instantly share code, notes, and snippets.

@tanakh
tanakh / gist:3017519
Created June 29, 2012 11:47
conduit-0.5, proxy server, simplified by using async-2.0
{-# LANGUAGE OverloadedStrings #-}
import Data.Conduit
import Data.Conduit.Network
import Data.Conduit.Text (encode, decode, utf8)
import qualified Data.Conduit.List as CL
import qualified Data.Conduit.Binary as CB
import Data.Text (toUpper)
import qualified Data.ByteString.Char8 as S8
@bleis-tift
bleis-tift / gist:2969500
Created June 22, 2012 00:32 — forked from forki/gist:2964839
Static duck typing (F#2.0)
let inline speak (a: ^a) =
let x = (^a : (member Name: string) (a))
printfn "I'm %s" x
let y = (^a : (member talk: unit -> string) (a))
printfn "I say %s" y
//type Duck =
// { Name : string } // Name is not property in F# 2.0
//
// member x.talk() = "quackity quack"
@etorreborre
etorreborre / gist:2952827
Created June 19, 2012 07:38
ScalaCheck Arbitrary instance for a Directed Acyclic Graph, using memoized generators to share previously generated values
/**
* Arbitrary instance for a CompNode: Load, ParallelDo, GroupByKey, Combine, Op or Return
*/
import scalaz.Scalaz._
import Gen._
/**
* we're using a sized generator where the size of the generated data will be the depth of the graph
* This allows to control the generation phase for ScalaCheck properties with minSize and maxSize
*/
@ckirkendall
ckirkendall / clojure-match.clj
Created June 15, 2012 02:26 — forked from bkyrlach/Expression.fs
Language Compare F#, Ocaml, Scala, Clojure, Ruby and Haskell - Simple AST example
(use '[clojure.core.match :only [match]])
(defn evaluate [env [sym x y]]
(match [sym]
['Number] x
['Add] (+ (evaluate env x) (evaluate env y))
['Multiply] (* (evaluate env x) (evaluate env y))
['Variable] (env x)))
(def environment {"a" 3, "b" 4, "c" 5})
@etorreborre
etorreborre / gist:2839993
Created May 31, 2012 01:01
Type inference trick to avoid unchecked - DOESN'T WORK... warnings in pattern matching
/**
* UPDATE: this trick doesn't work here because when using 'asInstanceOf', Nothing is inferred as being the expected type, thus the conversion fails at run-time.
*/
/**
* Let's say you have some ugly casting to do
*/
// this doesn't compile with something like: "expected _, got Any"
function match {
@rummelonp
rummelonp / faraday.md
Last active May 20, 2022 12:23
Ruby の HTTP クライアントライブラリ Faraday が便利そう

Ruby の HTTP クライアントライブラリ Faraday が便利そう

Ruby の HTTP クライアントライブラリ Faraday が便利そう

API ラッパの開発には [RestClient gem][rest_client_gem] だとか
OAuth の必要なものは [Net/HTTP][net_http] + [OAuth gem][oauth_gem] を使ってた

[Twitter gem][twitter_gem] や [Instagram gem][instagram_gem] など API ライブラリのソースを読んでみると
[Faraday gem][faraday_gem] というものがよく使われてた

@tototoshi
tototoshi / finagle_http_hello.scala
Created May 19, 2012 04:11
finagle-http で Hello, world.
package com.github.tototoshi.finagle_hack
import java.net.InetSocketAddress
import com.twitter.finagle.{Service, SimpleFilter}
import com.twitter.util.Future
import com.twitter.finagle.builder.{Server, ServerBuilder}
import com.twitter.finagle.http._
import com.twitter.finagle.http.path._
object HTTPServer {
@repeatedly
repeatedly / d_master.md
Last active June 8, 2023 06:20
D言語基礎文法最速マスター

他の言語をある程度知っている人はこれを読めばD言語の基礎をマスターでき,D言語の氷山の一角くらいは知ることができると思います.対象バージョンはdmd 2.059です.

1. 基礎

ソースファイル

ASCIIかUTFしか受け付けません.それ以外の文字コードで書くとコンパイルエラーになります.

main

D言語のmainはCとは違い以下のようなシグネチャです.

@matope
matope / NoSQLデータモデリング技法.markdown
Created April 16, 2012 03:35
NoSQLデータモデリング技法

#NoSQLデータモデリング技法

原文:NoSQL Data Modeling Techniques « Highly Scalable Blog

I translated this article for study. contact matope[dot]ono[gmail] if any problem.

NoSQLデータベースはスケーラビリティ、パフォーマンス、一貫性といった様々な非機能要件から比較される。NoSQLのこの側面は実践と理論の両面からよく研究されている。ある種の非機能特性はNoSQLを利用する主な動機であり、NoSQLシステムによく適用されるCAP定理がそうであるように分散システムの基本的原則だからだ。一方で、NoSQLデータモデリングはあまり研究されておらず、リレーショナルデータベースに見られるようなシステマティックな理論に欠けている。本稿で、私はデータモデリングの視点からのNoSQLシステムファミリーの短い比較といくつかの共通するモデリングテクニックの要約を解説したい。

本稿をレビューして文法を清書してくれたDaniel Kirkdorfferに感謝したいと思う

@everpeace
everpeace / README.md
Created March 27, 2012 08:39
Automata (DFA,NFA,εNFA) in Scala