Skip to content

Instantly share code, notes, and snippets.

View voidlizard's full-sized avatar

Dmitry Zuikov voidlizard

View GitHub Profile
+-ifndef( __CPE_PARAMETER_HRL__ ).
+-define( __CPE_PARAMETER_HRL__, 1).
+
+-define( NOTIFY_NONE , 0 ).
+-define( NOTIFY_PASSIVE, 1 ).
+-define( NOTIFY_ACTIVE , 2 ).
+
+-type notify() :: ?NOTIFY_NONE | ?NOTIFY_PASSIVE | ?NOTIFY_ACTIVE.
+
+-define( IS_NOTIFY(N), (N>=?NOTIFY_NONE andalso N=<?NOTIFY_ACTIVE) ).
#!/bin/sh
# This scripts control incomming and outcomming bandwight in a linux router box
# The linux box only have one eth0 connect to the local network and other to internet
# ifb0 is a a special device create only for limit the incomming bandwight in eth0
# It is configured for match a 192.168.1.0/24 network, with 255 hosts
# The limit for up/down is 20Mb (20480kbit), divide this bandwight for every host (in this case 80kbit)
wanif=eth2.2
-module(picoparser).
-export([ str/0
, str/1
, str_/0
, seq/1
, any/1
, whatever/0
, many/1
, match/1
@voidlizard
voidlizard / snafu.hs
Last active August 29, 2015 14:03
Functor?
{-# Language MultiParamTypeClasses, FlexibleInstances, TypeFamilies, GeneralizedNewtypeDeriving #-}
module Main where
-- Module A -- interface
import Control.Monad.State
import Data.Conduit
import qualified Data.Conduit.List as CL
class ISnafu t where
source :: MonadIO m => Int -> Source m BS.ByteString
source n = replicateM_ n $ do
n <- liftIO $ liftM (succ.(`mod` 15)) randomIO
s <- liftIO $ replicateM n (randomIO :: IO Word8)
yield (BS.pack s)
putter :: Putter BS.ByteString
putter s = do
{-# Language MultiParamTypeClasses
, TypeFamilies
, FlexibleContexts
, FlexibleInstances #-}
module Main where
import qualified Data.List as L
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as U
module CWriter where
import Prelude hiding (EQ, GT)
import Data.List
import Data.Functor.Identity
import Control.Monad.Writer
import Control.Monad.State
import Text.Printf
import EncodeVM
line :: Parser ()
line = do
a <- hexadecimal >> char ':'
b <- hexadecimal >> char ':'
c <- hexadecimal
skipSpace
s <- A.takeWhile (not.C.isSpace)
skipWhile endOfLine
return ()
ethParser = (try line <|> other) `sepBy` (char '\n')
other :: Parser (Maybe EthCode)
other = A.skipWhile (/= '\n') >> return Nothing
line :: Parser (Maybe EthCode)
line = do
a <- hexadecimal :: Parser Word8
char ':'
b <- hexadecimal :: Parser Word8
search = parseOnly (manyTill (anyChar *> pure False) (asciiCI "android" *> pure True) *> pure True) s