diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bea5755 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +TAGS diff --git a/compile.hs b/compile.hs index 1f405e8..650a46e 100755 --- a/compile.hs +++ b/compile.hs @@ -2,7 +2,7 @@ -- stack --install-ghc runghc --package turtle --resolver lts-5.5 --verbosity silent --package=ansi-terminal {-# LANGUAGE OverloadedStrings #-} -import Control.Arrow ((>>>)) +import qualified Control.Foldl as Fold import qualified Data.Text.IO as T import Filesystem.Path (addExtension, replaceExtension) import qualified Filesystem.Path as F @@ -10,60 +10,83 @@ import Prelude hiding (FilePath) import System.Console.ANSI import Turtle -data Options = Options { web :: Bool - , reveal :: Bool - , pdf :: Bool - , beamer :: Bool - , file :: Maybe FilePath - } deriving (Show) +-- Command Line Options +data Options = + Options { web :: Bool + , reveal :: Bool + , pdf :: Bool + , beamer :: Bool + , debug :: Bool + , file :: Maybe FilePath + } deriving (Show) parser :: Parser Options parser = Options <$> switch "web" 'w' "generate HTML web page" <*> switch "reveal" 'r' "generate HTML presentation using reveal" <*> switch "pdf" 'p' "generate PDF article" <*> switch "beamer" 'b' "generate PDF presentation using beamer" + <*> switch "debug" 'd' "debug mode (show commands)" <*> optional (argPath "file" "markdown file path") - -fgrep :: Pattern a -> Shell FilePath -> Shell FilePath -fgrep pat sp = do - fpath <- sp - _:_ <- return (match pat (either id id (toText fpath))) - return fpath +initOptions :: IO Options +initOptions = do + rawopts <- options "compile files" parser + return $ if web rawopts || reveal rawopts || pdf rawopts || beamer rawopts + then rawopts + else rawopts { web = True + , reveal = True + , pdf = True + , beamer = True } main :: IO () main = do - opts <- options "compile files" parser + opts <- initOptions sh $ do argfile <- case file opts of - Nothing -> fgrep (invert (prefix "./.")) $ find (has ".md") "." + Nothing -> findMarkdownFiles Just someFile -> return someFile liftIO $ do + when (debug opts) (yellowPrn ("-- " <> format fp argfile <> " --")) cd (directory argfile) - when (web opts) (toWeb argfile) - when (reveal opts) (toReveal argfile) - when (pdf opts) (toPdf argfile) - when (beamer opts) (toBeamer argfile) + when (web opts) (toWeb (debug opts) argfile) + when (reveal opts) (toReveal (debug opts) argfile) + when (pdf opts) (toPdf (debug opts) argfile) + when (beamer opts) (toBeamer (debug opts) argfile) -toWeb :: FilePath -> IO () -toWeb fpath = do - let dest = replaceExtension fpath "html" - pr :: FilePath - pr = F.concat $ map (const "..") (splitDirectories (directory fpath)) - prt :: Text - prt = format fp pr - void $ shell ("pandoc -s -mathjax -t html5" - <> "--template " <> prt <> " " - <> "--section-divs" - <> "--variable transition=linear" - <> "--variable prefix=" <> prt - <> "-o " <> format fp dest - <> format fp fpath) empty +-- | Find Markdown Files (skip hidden directories) +findMarkdownFiles :: Shell FilePath +findMarkdownFiles = fgrep (invert (prefix "./.")) $ find (has ".md") "." -toReveal :: FilePath -> IO () -toReveal fpath = do - let renameToDest = filename >>> dropExtension >>> flip addExtension "reveal" >>> flip addExtension "html" - dest = renameToDest fpath +-- | basic exec command with debug option and colors DONE or FAILED status +execcmd :: Bool -> FilePath -> Text -> IO () +execcmd dbg dest cmd = do + when dbg (T.putStrLn cmd) + T.putStr $ format fp dest <> " " + answer <- shell cmd empty + case answer of + ExitSuccess -> greenPrn "[DONE]" + ExitFailure _ -> redPrn "[FAILED]" + +-- | Generate HTML format +toWeb :: Bool -> FilePath -> IO () +toWeb dbg fpath = do + let dest = filename (replaceExtension fpath "html") + pr :: FilePath + pr = F.concat $ map (const "..") (splitDirectories (directory fpath)) + cmd = "pandoc -s -S --toc -mathjax -t html5 --smart " + <> "--css " <> format fp (pr "styling.css") <> " " + <> "-A " <> format fp (pr "footer.html") <> " " + <> "-o " <> format fp dest <> " " + <> format fp (filename fpath) + execcmd dbg dest cmd + +-- | Generate HTML Reveal.js Presentation +toReveal :: Bool -> FilePath -> IO () +toReveal dbg fpath = do + let dest = fpath |> filename + |> dropExtension + |> flip addExtension "reveal" + |> flip addExtension "html" pr :: FilePath pr = F.concat $ map (const "..") (splitDirectories (directory fpath)) template = pr "template-revealjs.html" @@ -76,26 +99,83 @@ toReveal fpath = do <> "--variable prefix=" <> prt <> " " <> "-o " <> format fp dest <> " " <> format fp (filename fpath) - T.putStr $ format fp dest <> " " - answer <- shell cmd empty - case answer of - ExitSuccess -> greenPrn "[DONE]" - ExitFailure _ -> redPrn "[FAILED]" + execcmd dbg dest cmd -toPdf :: FilePath -> IO () -toPdf = print +-- | Generate PDF Document using XeLaTeX +toPdf :: Bool -> FilePath -> IO () +toPdf dbg fpath = do + let dest = fpath |> filename + |> dropExtension + |> flip addExtension "pdf" + pr = F.concat $ map (const "..") (splitDirectories (directory fpath)) + template = pr "template.latex" + cmd = "pandoc -s -S -N --toc " + <> "--template=" <> format fp template <> " " + <> "--section-divs " + <> "--variable fontsize=14pt " + <> "--variable linkcolor=orange " + <> "--variable urlcolor=orange " + <> "--latex-engine=xelatex " + <> "-o " <> format fp dest <> " " + <> format fp (filename fpath) + execcmd dbg dest cmd -toBeamer :: FilePath -> IO () -toBeamer = print +-- | Generate Beamer Presentation PDF +toBeamer :: Bool -> FilePath -> IO () +toBeamer dbg fpath = do + mslideLevel <- fold (fpath |> filename + |> input + |> grep (prefix "slide_level: ") + |> sed (prefix "slide_level: " *> star digit)) + Fold.head + let slideLevel = maybe "2" (\l -> if l == "" then "2" else l) mslideLevel + dest = fpath |> filename + |> dropExtension + |> flip addExtension "beamer" + |> flip addExtension "pdf" + cmd :: Text + cmd = "pandoc -s -S -N " + <> "-t beamer " + <> "--slide-level=" <> slideLevel <> " " + <> "--variable fontsize=14pt " + <> "--variable linkcolor=orange " + <> "--variable urlcolor=orange " + <> "--latex-engine=xelatex " + <> "-o " <> format fp dest <> " " + <> format fp (filename fpath) + execcmd dbg dest cmd + + +-- # Colors Helpers (should be a sub lib) +-- import System.Console.ANSI + +prnColor :: Color -> Text -> IO () +prnColor c txt = do + setSGR [SetColor Foreground Dull c] + T.putStrLn txt + setSGR [Reset] greenPrn :: Text -> IO () -greenPrn txt = do - setSGR [SetColor Foreground Dull Green] - T.putStrLn txt - setSGR [Reset] +greenPrn = prnColor Green redPrn :: Text -> IO () -redPrn txt = do - setSGR [SetColor Foreground Dull Red] - T.putStrLn txt - setSGR [Reset] +redPrn = prnColor Red + +yellowPrn :: Text -> IO () +yellowPrn = prnColor Yellow + +-- | Helper to make code look a lot more (->) in Clojure +-- Generally humans, prefer to read function applied in the order +-- from left to right not in the reverse order. +-- This operator can be found in F# and Elm +(|>) :: a -> (a -> b) -> b +(|>) v fn = fn v + +-- # Grep Files helper + +-- | Same as grep put to be used after find or ls +fgrep :: Pattern a -> Shell FilePath -> Shell FilePath +fgrep pat sp = do + fpath <- sp + _:_ <- return (match pat (either id id (toText fpath))) + return fpath diff --git a/druid/druid.html b/druid/druid.html new file mode 100644 index 0000000..44bfb1b --- /dev/null +++ b/druid/druid.html @@ -0,0 +1,95 @@ + + + + + + + + Druid pour l’analyse de données en temps réel + + + + + +
+

Druid pour l’analyse de données en temps réel

+

Yann Esposito

+

7 Avril 2016

+
+ +

Intro

+

Plan

+ +

Expérience

+ +

Demande

+ +

En pratique

+ +

Origine (PHP)

+

History 

+

Introduction

+ +

DEMO

+

Druid

+

Who

+

Metamarkets

+

Goal

+
+

Druid is an open source store designed for real-time exploratory analytics on large data sets.

+
+
+

hosted dashboard that would allow users to arbitrarily explore and visualize event streams.

+
+

Concepts

+ +

Features

+ +

arbitrary exploration of billion-row tables tables with sub-second latencies

+

Proof

+ + + diff --git a/druid/druid.pdf b/druid/druid.pdf new file mode 100644 index 0000000..a7866f3 Binary files /dev/null and b/druid/druid.pdf differ diff --git a/druid/druid.reveal.html b/druid/druid.reveal.html index 82764f2..71f904c 100644 --- a/druid/druid.reveal.html +++ b/druid/druid.reveal.html @@ -9,7 +9,7 @@ - + @@ -130,7 +130,7 @@ center: false, // available themes are in /css/theme - theme: Reveal.getQueryHash().theme || 'solarized', + theme: Reveal.getQueryHash().theme || 'default', // default/cube/page/concave/zoom/linear/fade/none transition: Reveal.getQueryHash().transition || 'linear', diff --git a/druid/img/bad_php.jpg b/druid/img/bad_php.jpg new file mode 100644 index 0000000..98bb93d Binary files /dev/null and b/druid/img/bad_php.jpg differ diff --git a/template.latex b/template.latex index a143b15..79ede8e 100644 --- a/template.latex +++ b/template.latex @@ -102,6 +102,8 @@ $endif$ \definecolor{cyan}{RGB}{42,161,152} \definecolor{green}{RGB}{133,153,0} % ----------------------------------------- +\providecommand{\tightlist}{% + \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} \hypersetup{breaklinks=true, bookmarks=true, pdfauthor={$author-meta$},