IT練習ノート

IT関連で調べたこと(実際は嵌ったこと)を書いています。

2017-01-01から1年間の記事一覧

Tabularのインストール

vim

deinの設定ファイルにtabularのリポジトリを追加します。 設定ファイルの場所 ~/.dein.toml 設定内容 [[plugins]] repo = 'godlygeek/tabular' 使い方 ビジュアルモードで範囲を指定して下記コマンドを実行します。(範囲指定は必要ないはずなのですが、範囲…

フェルマーの小定理のテスト

gist.github.com

TraversableからFoldableを求める

From Traversable to Foldable

DeriveFoldableの練習

FoldableであるにはFunctorであることが前提です。そのため、Derivingの対象となるのは、型の最後のパラメータになります。 a sample of deriving foldable

Record syntaxを使うときに設定しておくと便利な言語拡張

Record syntax を使うときに設定しておくと便利な言語拡張 DuplicateRecordFields フィールド名の重複を許す。ただし、曖昧になる場合はエラーになる。 Prelude> :set -XDuplicateRecordFields Prelude> data Foo = Foo {x :: Int} Prelude> data Bar = Bar …

cabalでのtest実行

ライブラリのテストを実行しようとしたらそのままではテストが実行できませんでした。 Servant-Serverをgit cloneして、cabal testしたら依存関係ライブラリがないと指摘されます。 (root)bar:servant-server foo$ cabal test Re-configuring with test suit…

Servant API の変遷

HasServerのroute関数の変遷 class HasServer layout where type ServerT layout (m :: * -> *) :: * route :: ********* version implementation 0.2.1–0.4.0 route :: Proxy layout -> Server layout -> RoutingApplication 0.5–0.6 route :: Proxy layout…

Haskellの名前空間をまとめる実装

下記のようなコードがありVertex3のドキュメントを確認しようとおもったのですが、上手くドキュメントが見つけられませんでした。 import Graphics.Rendering.OpenGL as GL GL.vertex $ (GL.Vertex3 (-1) (-1) 0 :: GL.Vertex3 GL.GLfloat) Graphics.Renderi…

OpenGL (GLFW-b)

下記のチュートリアルをGLFW-bに書き換える。 OpenGLTutorial1 - HaskellWiki Haskell OpenGL Tutorial Rewrite for GLFW-b

ServantのType Familiesの理解の準備

Sec 4.2 of Servant Paper

ServantのAPIからHandlerへの型の流れを確認する

Servantのチュートリアルでは、2.2.3でチートシートのように説明されています。 https://media.readthedocs.org/pdf/haskell-servant/v0.6/haskell-servant.pdf combinator handelrのパラメータ 補足 Capture “something” a a QueryParam “something” a Mayb…

Learn Physics の導入

Learn Physics learn-physics: Haskell code for learning physics stackでインストールしてみます。 bar:graphics foo$ stack new graphics-work01 Downloading template "new-template" to create project "graphics-work01" in graphics-work01/ ... The …

Servantでipadress取得のサンプル

Servant IP Address Sample

ghcmod-vimのインストールで嵌った点

foo$ ls -al ~/.cache/dein/repos/github.com/eagletmt/ghcmod-vim/ total 80 drwxr-xr-x 18 foo staff 612 4 2 15:11 . drwxr-xr-x 4 foo staff 136 4 2 14:45 .. drwxr-xr-x 15 foo staff 510 4 2 19:00 .git -rw-r--r-- 1 foo staff 49 4 2 14:45 .gitign…

neovimの導入

neovimはbrewでインストールします。 https://github.com/neovim/neovim foo$ brew install neovim/neovim/neovim Updating Homebrew... ==> Auto-updated Homebrew! Updated 2 taps (homebrew/core, homebrew/php). ==> New Formulae alexjs dmtx-utils gte…

react-bootstrap-tableでcolumnが動的の場合のテーブル生成

Reactのテーブルコンポーネントはどれがデファクトなのでしょうか。よくわからなかったので、目についたreact-bootstrap-tableを使ってみました。 allenfang.github.io ライブラリの取り込み <script src="https://unpkg.com/react@15/dist/react.js"></script> <script src="https://unpkg.com/react-dom@15/dist/react-dom.js"></script>

ReactでHTMLの共通化

SBAdmin2のダッシュボードページにあるカードのUI部分をReactにて共通化してみました。 startbootstrap.com ここの部分です。 下記が4枚あるカードのコードになります。これをReactを使って共通化します。背景色と表示内容だけが異なり、タグの構造は全く同…

ServantのCSVファイルダウンロードのサンプル

Servant CSV download sample $ curl -i http://127.0.0.1:8081/csv/UNdata_Export_pork HTTP/1.1 200 OK Transfer-Encoding: chunked Date: Mon, 20 Jun 2016 16:12:16 GMT Server: Warp/3.2.9 Content-Type: application/csv "Country or Area","Year","Un…

HaskellのCSV読み込み

利用ライブラリ Text.CSV インポート Prelude> import Text.CSV 1行読み込み Prelude Text.CSV> parseCSVTest "aaa,bbb" [["aaa","bbb"]] Prelude Text.CSV> parseCSVTest "aaa,bbb,ccc" [["aaa","bbb","ccc"]] トリムはしない Prelude Text.CSV> parseCSVTe…

ServantのFileUploadサンプル

package servant-multipart: multipart/form-data (e.g file upload) support for servant $ cabal install servant-multipart Resolving dependencies... Notice: installing into a sandbox located at foo/.cabal-sandbox Downloading http-client-0.5.6.…

HaskellでYamlの任意項目の取り扱い

Applicativeスタイルで.*?で任意項目、.!=でデフォルト値を設定します。` parseJSON (Object m) = AppConfig <$> m .:? "port" .!= 8081 -- default a sample of reading a yaml file by Haskell

ghciのプロンプトをいい感じにする方法

いつも忘れるので備忘 coderwall.com >:set prompt "\ESC[34mλ> \ESC[m" λ> aa <interactive>:28:1: error: Variable not in scope: aa λ> :set prompt "\ESC[1;34m%s\n\ESC[0;34mλ> \ESC[m" *Main Control.Monad.Morph Control.Monad.Trans Control.Monad.Trans.Maybe Co</interactive>…

tidalをreplから使う

1: SuperColliderを起動する。 2: SuperDirtを起動する。 SuperDirt.start; 3: ghciを起動、ライブラリの取り込み $ cabal repl GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help Prelude> import Sound.Tidal.Context -- インポート 4: repl…

(solved) The pkg-config package 'libpcre' is required but it could not be found.

pkg-confgとして認識されているか確認する。 $ pkg-config --libs libpcre Package libpcre was not found in the pkg-config search path. Perhaps you should add the directory containing `libpcre.pc' to the PKG_CONFIG_PATH environment variable No …

ServantのFormサンプル

POSTでFormデータを送信するServantの実装サンプルを、本家サイトも含めて探していたのですが、見つけられませんでした。結果的にはとっても簡単でした。FromFormのインスタンスにするだけでした。 data Res = Res { ret :: Int} deriving (Eq, Show, Generi…

The pkg-config package 'libpcre' is required but it could not be found.

stackはcabal hellを解決してくれるはずですが、上手くいかないケースもあるようです。servant,persistent,mysqlの組み合わせで環境を作ろうとしましたができませんでした。 新規作成 foo$ stack new servant06 ghcを取得 foo$ stack setup リゾルバは8.3 re…

threejsのカメラ移動とライト移動のサンプル

threejs sample camera threejs sample light

PythonでBlenderのオブジェクトを操作する(Quaternion)

Quaternionを使ってオブジェクトを回転させます。 Math Types & Utilities (mathutils) — Blender 2.63.7 - API documentation オブジェクトの移動がわかりやすくなるように目安の円を描きます。 bpy.ops.mesh.primitive_circle_add(location=(0,0,0), radiu…

最小のServantのサンプル(3)

A simple servant sample of error

最小のServantのサンプル(2)

A simple servant sample of Capture