Skip to content

Instantly share code, notes, and snippets.

@ashiklom
Last active April 3, 2016 21:44
Show Gist options
  • Save ashiklom/412af086383a333b44f9fa1398f560a7 to your computer and use it in GitHub Desktop.
Save ashiklom/412af086383a333b44f9fa1398f560a7 to your computer and use it in GitHub Desktop.
Convert expert-mode code to a URL and download the corresponding figure from IRIDL
#!/bin/bash
infile=$1
outfile=${infile/code/gif}
if [ `head -n1 $infile` == "auxfig" ]; then
code=`tail -n +2 $infile`
echo "Auxfile"
auxfile=1
else
code=`cat $infile`
auxfile=0
fi
baseurl='http://iridl.ldeo.columbia.edu/'`echo $code | tr '\n' '/' | tr ' ' '/'`
url="$baseurl"'+.gif'
wget -O plot.gif $url
if [ $auxfile -eq 1 ]; then
baseurl="$baseurl"'.auxfig'
url="$baseurl"'+.gif'
wget -O leg.gif $url
gm convert plot.gif leg.gif -append $outfile
rm -rf plot.gif leg.gif
else
mv plot.gif $outfile
fi
docs := $(patsubst %.md, %.pdf, $(wildcard *.md))
images := $(patsubst %.code, %.gif, $(wildcard *.code))
all: $(images) $(docs)
%.pdf : %.md $(images)
pandoc -o $@ $<
%.gif : %.code
./code.to.url.sh $<
clean:
rm -rf *.pdf *.gif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment