Skip to content

Instantly share code, notes, and snippets.

View lotz84's full-sized avatar

Tatsuya Hirose lotz84

View GitHub Profile
resolver: lts-3.19
packages:
- '.'
- location:
git: [email protected]:bos/hdbc-mysql.git
commit: d43ea057019ff683f278f36af410f4d3cbc731bc
extra-deps:
- relational-record-0.1.2.0
@lotz84
lotz84 / gist:ec45b5ec25b4a276433e
Created December 16, 2015 08:03
Scala の環境を整える
```bash
$ brew update
```
##Scalaのインストール
```bash
$ brew install scala
$ brew install sbt
```
@lotz84
lotz84 / 1.unigram.hs
Last active December 9, 2015 08:10
Calculate unigram of Lovecraft's Dagon using multiset <https://hackage.haskell.org/package/multiset>.
import Data.List (sortOn)
import qualified Data.MultiSet as MultiSet
main :: IO ()
main = do
contents <- concat . map words . lines <$> readFile "dagon.txt"
mapM_ print . take 10 . reverse . sortOn snd . MultiSet.toOccurList . MultiSet.fromList $ contents
flags: {}
packages:
- '.'
extra-deps:
- GLURaw-1.5.0.2
- GLUT-2.7.0.3
- JuicyPixels-util-0.2
- ObjectName-1.1.0.0
- OpenGL-2.12.0.1
- OpenGLRaw-2.5.5.0
@lotz84
lotz84 / mynumber.hs
Last active November 13, 2015 05:06
import GHC.Int
validateMyNumber :: Int64 -> Bool
validateMyNumber myNumber
| length (show myNumber) <= 12 =
let (x:pn) = take 12 . map (`mod` 10) . iterate (`div` 10) $ myNumber
qn = [if n <= 6 then n + 1 else n - 5 | n <- [1..11]]
y = (`mod` 11) . sum . zipWith (*) qn $ pn
in x == if y <= 1 then 0 else (11 - y)
| otherwise = False
import Control.Monad.Trans.Maybe
import Control.Monad.IO.Class
import Data.List
env :: [(String, Int)]
env = [("x", 1), ("y", 2), ("z", 3)]
main :: IO ()
main = do
result <- runMaybeT $ do
@lotz84
lotz84 / stack.yaml
Created October 28, 2015 04:52
lts-3.11: HRR
resolver: lts-3.11
packages:
- '.'
extra-deps:
- HDBC-2.4.0.1
- HDBC-session-0.1.0.0
- names-th-0.1.0.1
- persistable-record-0.1.0.1
- relational-schemas-0.1.0.2
- sql-words-0.1.3.1
import Data.Binary (Binary)
import qualified Data.Binary as Bin
import qualified Codec.Compression.GZip as GZip
import qualified Data.ByteString.Lazy.Char8 as BL
pickle :: Binary a => FilePath -> a -> IO ()
pickle path = BL.writeFile path . GZip.compress . Bin.encode
unpickle :: Binary a => FilePath -> IO a
unpickle path = Bin.decode . GZip.decompress <$> BL.readFile path
import Data.List (sortOn)
import Data.Traversable (for)
import Github.Data
import Github.Repos
organizations :: [String]
organizations = [ "aws", "google", "facebook", "Microsoft", "cookpad", "CyberAgent"
, "DeNADev", "pepabo", "gree", "hatena", "kayac", "mixi-inc", "naver"
, "niftycloud", "pixiv", "rakuten-ws", "airbnb", "adobe-webplatform"
--