Skip to content

Instantly share code, notes, and snippets.

@ganeshv
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ganeshv/cb129ddc8917dce03493 to your computer and use it in GitHub Desktop.
Save ganeshv/cb129ddc8917dce03493 to your computer and use it in GitHub Desktop.
GDP time series - 2

GDP data for various countries, obtained from Quandl and plotted with pigshell

Similar to this, except we run the script in a non-interactive shell and dump output to the div. In most cases, the interactive shell is preferred as it gives the reader an opportunity of trying out their own variations, but occasionally you don't want the reader distracted by what's happening behind the curtain.

<!DOCTYPE HTML>
<html lang="en">
<head>
<link href="http://pigshell.com/v/0.6.2/pigshell.css" rel="stylesheet"/>
</head>
<body>
<div class="pigshell">
<div class="pmain2" id="pmain2">
<!--[if lte IE 11]>
<p class="warning">Pigshell is known to work on recent (~2013-14) versions of Firefox and Chrome. It is unlikely to work on other browsers like IE and platforms like the iPad.</p>
</p>
<![endif]-->
<p id="loading" class="info">Loading kernel...</p>
</div>
</div>
<![if gte IE 11]>
<script src="http://pigshell.com/v/0.6.2/libs.js"></script>
<script src="http://pigshell.com/v/0.6.2/pigshell.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var ps = pigshell,
sorry = "Pigshell is known to work on recent (~2013-14) versions of Firefox and Chrome. It is unlikely to work on other browsers like IE and platforms like the iPad.";
if (!ps.compatible()) {
$("#pmain2").prepend("<p class='warning'>" + sorry + "</p>");
}
ps.HttpFS.defaults.tx = 'direct';
ps.init({rooturi: 'http://pigshell.com/v/0.6.2/root.tar',
embedded: true}, ps.hef('#pmain2', function() {
var p = ps.popen(window.location + "main.sh", {stdout: "#pmain2"});
p.read({}, ps.hef('#pmain2', function(){}));
}));
});
</script>
<![endif]>
</body>
</html>
#!pigshell
mount http://pigshell.com/v/$(uname -r)/usr/ /usr
sh -s /etc/profile
sh -s /usr/share/misc/countries.sh
cat http://unixtheweb.com/pmedia/fun-with-quandl/world-gdp.csv | csv2js | rename -f $(sjoin , ODA.$countries^"_NGDPD - Value") -t $(sjoin , $countries) | read gdp
# BRICS GDP
echo $gdp | cut -f "Date,BRA,RUS,IND,CHN,ZAF" | chart -t tseries -o ytitle="GDP (billion USD)",title="BRICS GDP at Current Prices"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment