Skip to content

Instantly share code, notes, and snippets.

View taiki45's full-sized avatar

Taiki Ono taiki45

View GitHub Profile
@mcastelino
mcastelino / iptables-cheatsheet.md
Last active July 10, 2024 08:51
iptables-cheatsheet

The netfilter hooks in the kernel and where they hook in the packet flow

The figure below calls out

  • The netfilter hooks
  • The order of table traversal
@myuon
myuon / lens-cheatsheet.md
Created April 6, 2014 06:41
Lens CheatSheet
@taiki45
taiki45 / ParserCombinator.hs
Last active June 27, 2022 14:14
http://d.hatena.ne.jp/tanakh/20040731 を読んでパーサを Applicative instance にしてみた
module ParserCombinator
( Parser
, parse
, satisfy
, char
, digit
, natural
, token
, oneOf
, listOf
@lestrrat
lestrrat / gist:9104980
Last active August 3, 2017 21:55
ヘビメタ英語を日常で使う風景
@tanakh
tanakh / gist:8303232
Created January 7, 2014 17:40
Haskellでループみたいなん
import Control.Monad
import Control.Monad.Trans
import Control.Monad.Trans.Loop
main :: IO ()
main = do
putStrLn $ "Can you guess the number I have?"
repeatLoopT $ do
a <- liftIO $ readLn
liftIO $ putStrLn $ "You said: " ++ show a
@myuon
myuon / while.hs
Created January 7, 2014 14:03
whileを使ったループ(多分分かりやすくはない)
import Control.Monad
while :: (Monad m) => (a -> Bool) -> m a -> m a
while f m = do
a <- m
when (f a) $ while f m >> return ()
return $ a
main = do
putStrLn $ "Can you guess the number I have?"
@rosylilly
rosylilly / 00-actor.rb
Last active March 3, 2017 07:03
分かった気になる DCI 、ロミオとジュリエット編 Romeo & Juliette with DCI
# 役者クラス
#
# say: 役者は声を発する事ができる。
class Actor
def say(words)
puts words
end
end
@VoQn
VoQn / 型って雄弁だね.hs
Last active September 23, 2023 14:16
まぁHaskellさんの真骨頂はモナド(あくまでも市井で言われてるようなレベルの話)より型と型クラスじゃないかなーと最近は思いますね
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
newtype FizzBuzz = FizzBuzz Int deriving (Enum, Eq, Ord, Num, Real, Integral)
instance Show FizzBuzz where
show x = (fizz ++ buzz) `or` show asInt where
fizz | ifMultipleOf 3 = "fizz" | otherwise = []
buzz | ifMultipleOf 5 = "buzz" | otherwise = []
ifMultipleOf n = x `mod` n == 0
or [] ys = ys
@tanakh
tanakh / gist:8006086
Created December 17, 2013 14:51
fizzbuzz
fizzbuzz :: Int -> String
fizzbuzz n = fromMaybe (show n) $
(guard (n `mod` 3 == 0) >> pure "Fizz") <>
(guard (n `mod` 5 == 0) >> pure "Buzz")
main :: IO ()
main = forM_ [1..100] $ putStrLn . fizzbuzz
@tanakh
tanakh / gist:7764127
Created December 3, 2013 05:04
新人女子にHaskellを教え込むHaskellerの鑑 https://paiza.jp/poh/ec-campaign あなたの部署に配属された新人女子プログラマの野田さんのコードをより良いものに直してください。野田さんは実はあなたの会社の社長令嬢。効率の良いコードに書き換えて、プログラマとしてのスキルをアピールできれば昇進するチャンスです。
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Control.Monad.ST
import Control.Applicative
import qualified Data.Vector.Unboxed as V
import Data.Vector.Unboxed ((!))
import qualified Data.Vector.Algorithms.Intro as Intro
isort v = runST $ do