Skip to content

Instantly share code, notes, and snippets.

View furu's full-sized avatar

furu furu

View GitHub Profile

Keybase proof

I hereby claim:

  • I am furu on github.
  • I am tfrkd (https://keybase.io/tfrkd) on keybase.
  • I have a public key ASDNZNG2QCki95C0WK-izxpJabYQQFiBxXvCFPv27VfbDgo

To claim this, I am signing this object:

{-# LANGUAGE OverloadedStrings #-}
import Network.HTTP.Simple
main :: IO ()
main = do
resp <- httpLBS "HEAD https://httpbin.org/get"
putStrLn $ "Status: " ++ show (getResponseStatus resp)
putStrLn $ "Headers: " ++ show (getResponseHeaders resp)
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.ByteString.Lazy.Char8 as L8
import Network.HTTP.Simple
main :: IO ()
main = do
resp <- httpLBS "https://httpbin.org/get?query=hello world"
L8.putStrLn $ getResponseBody resp
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.ByteString.Lazy.Char8 as L8
import Network.HTTP.Simple
main :: IO ()
main = do
resp <- httpLBS "https://httpbin.org/get"
putStrLn $ "Status: " ++ show (getResponseStatus resp)
putStrLn $ "Headers: " ++ show (getResponseHeaders resp)
main = undefined
-- | 商品を買えるか調べる関数
--
-- 「所持金 (money)」と「商品の値段 (price)」を渡すと、
-- 購入可能なら True、購入不可能なら False を返す。
--
-- >>> canBuy 100 300
-- False
--
import Control.Spoon (spoon)
import Control.DeepSeq (NFData)
predMay :: (Enum a, NFData a) => a -> Maybe a
predMay = spoon . pred
pred3 :: (Enum a, NFData a) => a -> Maybe a
pred3 x = return x >>= predMay >>= predMay >>= predMay
predN :: (Enum a, NFData a) => Int -> a -> Maybe a
import System.Random
main :: IO ()
main = do
gen <- getStdGen
putStrLn $ message $ dice1d100 gen
dice1d100 :: StdGen -> Int
dice1d100 gen = fst $ randomR (1, 100) gen
import System.Random
main :: IO ()
main = do
gen <- getStdGen
let (n, _) = randomR (1, 100) gen :: (Int, StdGen)
putStrLn $ "サイコロの結果は" ++ show n ++ "です!"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@furu
furu / unicorn.init
Last active June 10, 2016 11:56
sinatra アプリケーションを unicorn で動かすときの unicorn の init スクリプト
#!/bin/sh
# chkconfig: 345 60 40
# description: unicorn application server
# processname: unicorn
USER="ec2-user"
APP_ENV="production"
APP_ROOT="/home/ec2-user/www/foo/current"
UNICORN_CONF_FILE="$APP_ROOT/config/unicorn.rb"