Skip to content

Instantly share code, notes, and snippets.

View lotz84's full-sized avatar

Tatsuya Hirose lotz84

View GitHub Profile

Ethereum Dapp

Dapps とは

  1. アプリケーションは、オープンソースであること。オペレーションは自動であり、中央のコントロール主体を持たないこと。トークン、データ、レコード、などにつき、暗号化されて分散化されたブロックチェーンを利用していること。
  2. アプリケーションは、オープンに流通可能な、暗号トークンを持っていること。アプリケーションの利用に際してトークンを利用すること。参加者には、そのトークンによってリワード(報酬)が支払われること。
  3. アプリケーションはマーケットやユーザーからの改善要求によりプロトコルを改善していくこと。この改善は、ユーザーのコンセンサスによること。
@lotz84
lotz84 / haskell_maxims_and_arrows.md
Created February 2, 2017 15:05
Haskell Maxims and Arrows という Reddit の投稿が面白かったので訳しました

以下 Haskell Maxims and Arrows の翻訳


私は2001年から仕事でもプライベートでもHaskellを書いてきました。仕事で書いていたのはそのうち3年のことです。これらは私が学んだことです…

  1. Haskellは理解すれば理解するほどきれいに書けることを約束してくれます。信頼してください
  2. 常にパターンを探しましょう。単純になるとき、またその時だけそれらを抽象化するのです
  3. 辛抱強く抽象化を正しく理解しましょう。もしそれが出来たならすべてのことが魔法のようにつじつまが合うようになるでしょう。
  4. 実装そのものが設計図となります
@lotz84
lotz84 / ista.cabal
Created November 29, 2016 15:30
ISTA, Haskell implementation
name: ista
version: 0.1.0.0
build-type: Simple
cabal-version: >=1.10
executable app
main-is: ista.hs
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends: base
, mwc-random
@lotz84
lotz84 / sgd.hs
Last active October 16, 2016 05:36
{-# LANGUAGE RankNTypes #-}
module Main where
import Control.Monad
import Control.Monad.IO.Class (MonadIO, liftIO)
import Control.Monad.Morph (hoist, generalize)
import Control.Monad.State (State, StateT)
import qualified Control.Monad.State as State
import Data.List (genericLength)
@lotz84
lotz84 / rankn.hs
Created October 9, 2016 07:52
Line 10 is correct but line 11 is incorrect.
{-# LANGUAGE RankNTypes #-}
action :: ((forall s. s -> s) -> IO ()) -> IO ()
action f = f id
f :: (forall s. s -> s) -> ()
f _ = ()
main = do
action (\x -> pure $ f x)
@lotz84
lotz84 / 0_example.hs
Last active May 1, 2016 02:51
SpockでPOSTリクエストを受け付けてみる
$ curl -XPOST -d'name=Alice' -d'age=15' http://localhost:8080/person
Person {name = "Alice", age = 15}
$ curl -XPOST -d'name=Bob' -d'age=16' http://localhost:8080/person
Person {name = "Bob", age = 16}
$ curl -XPOST -d'name=Carol' -d'age=abc' http://localhost:8080/person
Bad Request.
$ curl http://localhost:8080/person
{-
- 株データAPI
- http://www.orenokabu.com/apis
-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
{-# LANGUAGE OverloadedStrings #-}
import Control.Concurrent (threadDelay)
import Control.Lens
import Control.Monad.IO.Class (liftIO)
import Control.Monad.State
import Data.List (nub, isPrefixOf)
import Data.Text.Lazy.Encoding (decodeUtf8)
import Data.Text.Lens (unpacked)
import qualified Network.Wreq as Wreq
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Monad (when)
import qualified Data.Vault.Lazy as Vault
import Data.ByteString.Char8 (ByteString, pack)
import Data.ByteString.Lazy.Char8 (fromStrict)
import Data.Text (Text)
@lotz84
lotz84 / kmeans.hs
Created January 6, 2016 02:37
k-means clustering example using iris data set https://archive.ics.uci.edu/ml/datasets/Iris
import Data.List
import Data.List.Extra
import Data.Maybe (mapMaybe)
import System.Random (randomRIO)
import qualified Data.IntMap as IntMap
import Data.Foldable (for_)
import qualified Data.Map as Map
kmeans :: Ord b => (a -> a -> b) -> ([a] -> a) -> Int -> Int -> [a] -> IO [[a]]