Dexy Business Cards

March 19, 2011   ·   By   ·   Comments Off   ·   Posted in Uncategorized

If you met me at a conference recently, you probably got one of my very dexy business cards. I love the idea of business cards which are useful in some way, and these are business cards which are also mini demos of Dexy, not to mention the awesomeness of having business cards with source code!

I’m down to the very last card of my first order from Moo (except for the 4 I’m keeping for myself – 1 of each design), so as I’m about to order more, it occurred to me that I haven’t actually blogged about them yet. To make up for this omission, I made the first Dexy screencast talking about how the cards are made.

If you want to get into the nitty gritty of using Dexy with LaTeX files, then you can watch Part 1, which talks about LaTeX preambles and goes through what gets written to a Dexy log file. If you’re not in the mood right now and just want to see some pretty PDFs being generated, then feel free to skip ahead to Part 2. Or just keep scrolling and you’ll find the source code for all 4 of my card designs below.

Part 1

Part 2

Source Code

Below is the source code for each of the 4 card designs in my first batch. (Note the PNG image files below aren’t quite as crisp as the original PDFs they were rendered from.) I’ll be coming up with some new designs soon. I’m a fan of Moo because their cards look great (I went for the green stock, very happy with it), but most importantly Moo’s printfinity meant I was able to print multiple card designs. (If you’re curious, the R card was the most popular, which was probably due to my choice of conferences as well as the fact that it had a lovely sparkly graph.)

If you’d like to use these as templates for your own cards, then please feel free. I’d love to hear from you if you do!

Card 1

C source code:

#include <stdio.h>

    printf("HELLO, world\n");

LaTeX source:

<< d['001.c|pyg|l'] >>

\noindent Dexy says:
<< d['001.c|c'] >>

Card 2

R source code:

filename = "dexy--random-spark.pdf"
pdf(file=filename, width=2.5, height=1)
### @export "spark"
sparkline(rnorm(10), ptopts = 'first.last',
    margins=unit(c(0.2,0.2,0.2,0.6), 'inches'),
    IQR=gpar(fill="#F7ECDA", col='#F7ECDA'))
### @end

LaTeX source:

\noindent Dexy loves R:
<< d['sections']['002.R|fn|idio|rint|pyg|l']['spark'] >>
\includegraphics{<< d['a']['random-spark'] >>}

Card 3

Clojure source code:

(def hi (fn [] "Hello world"))

LateX source:

<< d['003.clj|pyg|l'] >>

\noindent Dexy says:
<< d['003.clj|clj'] >>

By the way, if you’re a Clojure fan and interested in Dexy you might consider writing a Pygments lexer for Clojure transcripts, so that examples like this can be syntax highlighted. (There’s a lexer for pure Clojure source code but not for Clojure console sessions.)

Card 4

Python source code:

from turtle import *

s = Screen()

### @export "turtle"
for i in range(24):
### @end               

print s.getcanvas().postscript()

LaTeX source:

<< d['sections']['004.py|idio|l']['turtle'] >>
\makebox[1in][r]{\includegraphics[width=0.8in]{<< filenames['004.py|py|ps2pdf'] >>}}
\noindent Dexy can turtle :-)

The full source code can be found on bitbucket.