Last active
October 3, 2016 18:01
-
-
Save jswrenn/0dec9caead0969936336263d99c1058f to your computer and use it in GitHub Desktop.
Bash Client for Critical Review
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
<?xml version="1.0"?> | |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<xsl:output method="text"/> | |
<xsl:template match="/other-reviews"> | |
<xsl:for-each select="review-header"> | |
<xsl:value-of select="@edition"/> | |
<xsl:text> </xsl:text> | |
<xsl:value-of select="enrollment"/> | |
<xsl:text>
</xsl:text> | |
</xsl:for-each> | |
</xsl:template> | |
</xsl:stylesheet> |
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
function critical-stats() { | |
# Usage: | |
# $ critical-stats CSCI 1730 | |
curl -s "http://www.thecriticalreview.org/$1/$2" \ | |
| xmllint --format - \ | |
| tee >( xmllint --xpath /cr/view/review - \ | |
| tee >( xmllint --xpath '/review/title/text()' - \ | |
| xargs -0 printf 'Title:\t\t%s\n' ) \ | |
>( xmllint --xpath '/review/crn/text()' - \ | |
| xargs -0 printf 'CRN:\t\t%s\n' ) \ | |
>( xmllint --xpath 'string(/review/@edition)' - \ | |
| xargs -0 printf 'Last Edition:\t%s\n' ) \ | |
>( xmllint --xpath '/review/tally/minhours_mean/text()' - \ | |
| xargs -0 printf 'Avg (hr/week):\t%s\n' ) \ | |
>( xmllint --xpath '/review/tally/maxhours_mean/text()' - \ | |
| xargs -0 printf 'Max (hr/week):\t%s\n' ) \ | |
> /dev/null | cat ) \ | |
>( xmllint --xpath /cr/view/other-reviews - \ | |
| xsltproc .critical-stats-enrollment.xslt - \ | |
| sort \ | |
| gnuplot -p -e \ | |
"set terminal dumb $(tput cols),$(expr $(tput lines) / 2 ); | |
set style data histogram; | |
set yrange [0:*] reverse; | |
p '<cat' title '' with lines" \ | |
; printf "Enrollment:\n" ) \ | |
> /dev/null | tac | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment