I love Haskell.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"also my gist test | |
"get words count of current line | |
echo "current line words count : ".len(split(getline("."))) | |
"Double Pinyin Schema | |
let s:yunmu={ "iu": "q", "ia": "w", "ua": "w", "e": "e", "uan": "r", "er": "r", "ue": "t", | |
\ "uai": "y", "v": "y", "u": "u", "i": "i", "uo": "o","o":"o", "un": "p", | |
\ "a":"a","ong":"s","iong":"s","uang":"d","iang":"d","en": "f","eng":"g", | |
\ "ang": "h", "an": "j", "ao": "k", "ai":"l", "ing":";", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- remove first long comment in a directory's all .h and .c file and it's all sub directory | |
import System.Environment | |
import System.Directory | |
import System.FilePath.Windows | |
import Control.Monad | |
import Data.List | |
-- 必须保证/*和*/是匹配的...这里满足这个条件 | |
removeFirstComment :: String -> String | |
removeFirstComment [] = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import System.Directory | |
import Control.Monad | |
selectM :: Monad m => (a -> m Bool) -> ([a], [a]) -> a -> m ([a], [a]) | |
selectM p ~(ts,fs) x = do | |
r <- p x | |
if r then return (x:ts, fs) else return (ts, x:fs) | |
partitionM :: Monad m => (a -> m Bool) -> [a] -> m ([a],[a]) | |
partitionM p xs = do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c = let x = 0 : y | |
y = 1 : x | |
in | |
x | |
-- c [0,1,0,1...] | |
-- 这种技巧是用来使用data来实现图,双向链表等结构的 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################ Lispy: Scheme Interpreter in Python | |
## (c) Peter Norvig, 2010; See http://norvig.com/lispy.html | |
################ Symbol, Procedure, Env classes | |
from __future__ import division | |
Symbol = str | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DeriveDataTypeable #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE RecordWildCards #-} | |
import Network.Wai | |
import Control.Exception (Exception, throwIO, assert) | |
import Control.Applicative ((<$>)) | |
import Control.Monad (when, forever, unless) | |
import Data.Typeable (Typeable) | |
import Network.HTTP.Types (status200, status404) | |
import Network.Wai.Handler.Warp (run) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Shell script to install your public key on a remote machine | |
# Takes the remote machine name as an argument. | |
# Obviously, the remote machine must accept password authentication, | |
# or one of the other keys in your ssh-agent, for this to work. | |
ID_FILE="${HOME}/.ssh/id_rsa.pub" | |
if [ "-i" = "$1" ]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Csv | |
import Control.Monad | |
import Control.Applicative | |
-- 2014-07-24 15:26:22 fail and mzero | |
data Test = A | B | C | |
deriving (Show, Read) | |
instance FromField Test where |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import qualified Data.HashSet as HS | |
import Data.Hashable | |
-- 2014-07-25 20:27:29 | |
-- TODO custom HashSet with special ``insert`` ``fromListWith`` ... | |
data Test = A Int | B Double | C Char | D | |
deriving (Show) | |
instance Eq Test where |
OlderNewer