Skip to content

Instantly share code, notes, and snippets.

@jgm
jgm / tricky
Created September 17, 2014 16:00
Recursively nested strong/emph
*a
**a
*a
**a
*a
**a
*a
**a
*a
**a
@jgm
jgm / scanners.c
Created November 16, 2014 23:04
scanners.c generated on osx by re2c 0.13.6
/* Generated by re2c 0.13.6 on Sun Nov 16 15:04:02 2014 */
#include <stdlib.h>
#include "chunk.h"
#include "scanners.h"
int _scan_at(int (*scanner)(const unsigned char *), chunk *c, int offset)
{
int res;
unsigned char *ptr = (unsigned char *)c->data;
unsigned char lim = ptr[c->len];
# These commands will proxy /xyz to port 9094
ProxyPreserveHost On
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
RewriteRule ^/xyz(.*)$ http://127.0.0.1:9094$1 [P,L]
ProxyPassReverse /xyz http://127.0.0.1:9094
-- return a fixed user
-- note: you'll have to register a user named "user" before making this change
getLoggedInUser :: MonadIO m => Params -> m (Maybe String)
getLoggedInUser params = return $ Just "user"
@jgm
jgm / gist:757798
Created December 28, 2010 22:08
A pandoc table
-------------------------------------------------------------
Centered Default Right Left
Header Aligned Aligned Aligned
----------- ------- --------------- -------------------------
First row 12.0 Example of a row that
spans multiple lines.
Second row 5.0 Here's another one. Note
the blank line between
rows.
@jgm
jgm / MakeManPage.hs
Created January 17, 2011 00:35
revised version to help find problem with MacPorts install...
-- Create pandoc.1 man page from README
import Text.Pandoc
import Data.ByteString.UTF8 (toString, fromString)
import Data.Char (toUpper)
import qualified Data.ByteString as B
import Control.Monad
import System.FilePath
main = do
rmContents <- liftM toString $ B.readFile "README"
@jgm
jgm / gist:1115661
Created July 30, 2011 15:45
HeX macro definition for \lettrine{T}{he}
lettrine :: Format -> InlineDoc -> InlineDoc -> Doc
lettrine "html" (InlineDoc x) (InlineDoc y) =
inTags "span" [("class","lettrine")] x +++ y
lettrine "latex" (InlineDoc x) (InlineDoc y) =
ctl "lettrine" +++ grp [x] +++ grp [y]
@jgm
jgm / gist:1431411
Created December 4, 2011 21:56
shell for script to turn pandoc math to svg
-- math2svg.hs
-- compile with:
-- ghc --make math2svg.hs
-- run using:
-- pandoc -t json -s | ./math2svg | pandoc -f json
import Text.Pandoc
import Text.JSON.Generic
main = getContents >>= transform . decodeJSON >>= putStrLn . encodeJSON
@jgm
jgm / knot.hs
Created August 15, 2012 03:41
Demonstration of a ParserT wrapping a Knot
-- This parses a simple language that allows word substitutions
-- to be defined.
--
-- Definitions are of the form WORD=WORD (where a WORD is a sequence
-- of letters). They may occur anywhere in the document, and they
-- will cause the WORD on the left to be replaced by the WORD on
-- the right anywhere in the document (before or after the
-- definition). Note that the WORD on the right may itself
-- be defined. So, for example, the input
--
@jgm
jgm / BenchIsSpace.hs
Created October 28, 2012 04:04
Benchmark of various reimplementations of Data.Char.isSpace
{-# OPTIONS_GHC -Wall -fwarn-tabs #-}
{-# LANGUAGE ForeignFunctionInterface #-}
----------------------------------------------------------------
-- Modified by John MacFarlane from an earlier benchmark by
-- wren ng thornton.
---------------------------------------------------------------
module Main (main) where
import qualified Data.Char as C
import Foreign.C.Types (CInt(..))