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
template <int n, typename Iterator> | |
class nth_iterator | |
{ | |
public: | |
typedef typename std::iterator_traits<Iterator>::iterator_category iterator_category; | |
typedef typename std::iterator_traits<Iterator>::value_type value_type; | |
typedef typename std::iterator_traits<Iterator>::difference_type difference_type; | |
typedef typename std::iterator_traits<Iterator>::pointer pointer; | |
typedef typename std::iterator_traits<Iterator>::reference reference; | |
typedef Iterator iterator_type; |
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
int ints[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; | |
for (int i = 1; i < 1000000; ++i) std::next_permutation(ints, ints+10); | |
for (int i = 0; i < 10; ++i) std::cout << ints[i]; |
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
prefixOf [] _ = True | |
prefixOf (x:xs) (y:ys) = x == y && xs `prefixOf` ys | |
prefixOf _ _ = False | |
subListOf l [] = null l | |
subListOf l m@(_:ys) = l `prefixOf` m || l `subListOf` ys | |
--not sure if ghc transforms the above, but here's a tail recursive version | |
subListOf' l [] = null l | |
subListOf' l m@(_:ys) |
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 NoMonomorphismRestriction #-} | |
import Text.Parsec | |
import Data.List.Split (splitOn) | |
--field = lexeme $ noneOf " " | |
field = manyTill anyChar space | |
logline = do | |
try (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
{-# LANGUAGE NoMonomorphismRestriction, FlexibleContexts #-} | |
module Parsers | |
(getCategoryAndEvent, getFields) | |
where | |
import Data.Attoparsec.Lazy | |
import qualified Data.ByteString.Lazy.Char8 as B | |
import qualified Data.ByteString.Char8 as SB | |
import Data.List (sort) | |
spaces :: Parser () |
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
{badmatch, | |
{error, | |
{{{function_clause, | |
[{rabbit_queue_index,journal_minus_segment1, | |
[{no_pub,del,ack},undefined]}, | |
{rabbit_queue_index,'-journal_minus_segment/2-fun-0-',4}, | |
{array,sparse_foldl_3,7}, | |
{array,sparse_foldl_2,9}, | |
{rabbit_queue_index,'-recover_journal/1-fun-0-',1}, | |
{dict,map_bucket,2}, |
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.PSQueue | |
data Element = E Int String deriving (Show) | |
type Buffer = PSQ Int Element | |
instance Eq Element where | |
(E a _) == (E b _) = a == b | |
instance Ord Element where | |
(E a _) < (E b _) = a < b |
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
from kazoo.client import KazooClient | |
config = { | |
'consumer_group': '<%= @consumer_group %>', | |
'topic': '<%= @topic %>' | |
} | |
def main(): | |
zk = KazooClient() | |
zk.start() |
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
while true; do | |
echo "hlogster.test.count $i $(date +%s)" | /opt/graphite/bin/carbon-client.py localhost:2003:a; | |
echo $i | |
i=$((i+1)) | |
i=$((i%10)) | |
sleep 1 | |
done |
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
-- tst | |
import Control.Concurrent.Chan | |
import Control.Concurrent | |
import Control.Exception (finally) | |
import System.IO.Unsafe (unsafePerformIO) | |
type Result = Int | |
execute_pig::String-> IO Result |
OlderNewer