Skip to content

Instantly share code, notes, and snippets.

hello = SayHello "/helloworld.Greeter/SayHello" . HelloRequest
main :: IO ()
main = do
c_grpc_init
channel <- channelCreate "localhost:50051" (ChannelArgs nullPtr)
context <- newClientContext channel
invokeCall context (hello "Haskell") >>= print
channelDestroy channel
@kolmodin
kolmodin / rust-json.rs
Created June 8, 2013 07:01
Rust code - type error.
fn getString(json: std::json::Json, key: ~str) -> Option<~str> {
match json {
std::json::Object(map) => {
match map.find(&key) {
Some(&std::json::String(str)) => Some(~"return str here"),
_ => None
}
},
_ => None
}
@kolmodin
kolmodin / editor.cljs
Created June 29, 2012 19:53
Looking for idiomatic version of something like this
;; part of my 100 first lines of clojure/clojurescript
;; not finished... not working.
(defn withHints [editor hints]
(defn insert [str] (.replaceRange editor str (.-from result) (.-to result)))
(let [completions (.-list hints)]
(cond
(= 1 (.-length completions)) (insert (first completions)))
(let [complete (.createElement js/document "div")
@kolmodin
kolmodin / dist.hs
Created April 17, 2012 17:40 — forked from rojepp/gist:2405633
Levenshtein imp vs memo rec
import qualified Data.ByteString as B
import qualified Data.ByteString.Unsafe as B
import Control.Applicative
import Control.Monad.ST
import Data.Array.Base ( unsafeRead, unsafeWrite )
import Data.Array.ST
dist :: B.ByteString -> B.ByteString -> Int