Skip to content

Instantly share code, notes, and snippets.

View lotz84's full-sized avatar

Tatsuya Hirose lotz84

View GitHub Profile
import System.Random
main = do
gen1 <- getStdGen
let rand = getRandom gen1
print . showKiyoshi . getKiyoshi $ rand
text :: [String]
text = ["zun", "doko", "kiyoshi"]
import System.Random
import Control.Monad
main :: IO()
main = print showKiyoshi
getRandomInt :: IO Int
getRandomInt = getStdRandom $ randomR (0,1) :: IO Int
text :: [String]
@twiecki
twiecki / bayesian_neural_network.ipynb
Last active February 22, 2022 01:28
Bayesian Neural Network in PyMC3
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tdoris
tdoris / Promises.md
Last active November 10, 2023 01:15

Does Haskell make promises it can't keep?

or The big problem with wrapping numeric types

When coding financial calculations, it's common to have a variety of numeric values such as Quantity, Price, Amount and so on. In quant finance, these usually refer to the Price observed in the market, a Quantity of shares. A Quantity of shares all traded at a given Price in a given currency will give you an Amount of that currency (the total value of the trade).

It's simple and fun exercise to write the functions you'd need to perform all the correct ways of combining Price, Quantity and Amount. There are a couple of things that don't work as you might expect (e.g., multiplication is ok but you need to think about division semantics.).

Many Haskell tutorials encourage the coder to wrap Double and Int in newtypes like this, so the compiler can help by detecting incorrect combinations of the different types, and so the code documents itself better. e.g.

@mathink
mathink / length_as_natrans.v
Last active November 20, 2015 11:42
length は リスト函手から定数函手への自然変換だよ on Coq.
Set Implicit Arguments.
Unset Strict Implicit.
Require Import Setoids.Setoid Morphisms.
Generalizable All Variables.
Class Setoid :=
{
carrier: Type;
equal: carrier -> carrier -> Prop;
@karpathy
karpathy / min-char-rnn.py
Last active May 19, 2025 10:44
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@fabichirox
fabichirox / list.md
Last active August 29, 2015 14:24
2015/07/05 日報

できるようになったこと

  • git の仕組みの薄い理解
  • herokuでpythonのappをデプロイ
  • 公開鍵の考え方の理解

できてなくてやりたいこと

  • bottle-yotoslack

インスコしたもの

  • python 3.2
@fabichirox
fabichirox / list.md
Last active August 29, 2015 14:23
2015/06/27 できるようになったこと

できるようになったこと

  • Curl コマンドの基礎
  • Curl コマンドでYo API
  • Yoall/
  • git commit
  • OSS commit
  • hubotをherokuで動かす
  • ssh key 設定
  • while true do done
@xeno14
xeno14 / gist:6188291aedcb2cd2dc15
Created June 15, 2015 14:30
Compile-time calculation of Pi
#include <cstdio>
#include <ratio>
template <typename R, intmax_t N>
struct ratio_pow {
using prev = typename ratio_pow<R, N-1>::value;
using value = std::ratio<R::num * prev::num, R::den * prev::den>;
};
template <typename R>
@avieth
avieth / gist:334201aa341d9a00c7fc
Last active July 22, 2022 13:42
Interpreting Free Monads of Functor Sums
Interpreting Free Monads of Functor Sums
========================================
This text deals with a way to compose certain kinds of monads, thereby mixing
their capabilities. It is a literate Haskell file, so let's begin with a
bunch of noise.
> {-# LANGUAGE MultiParamTypeClasses #-}
> {-# LANGUAGE FlexibleInstances #-}
> {-# LANGUAGE FlexibleContexts #-}