<commit_before><!DOCTYPE html>
<html>
<head>
<script src="http://yui.yahooapis.com/3.14.1/build/yui/yui.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<style>
 
body {
  font: 10px sans-serif;
}
 
.axis path,
.axis line {
  fill: none;
  stroke: #000;
  shape-rendering: crispEdges;
}
 
.area {
  fill: steelblue;
}
 
</style>

</head>
<body>
  <pre></pre>
  <div id="viz"></div>
  <script>
YUI({
    groups: {
        'cdnjs': {
            base : '//cdnjs.cloudflare.com/ajax/libs',
            modules: {
                'moment' : {
                    path: '/moment.js/2.0.0/moment.min.js'
                },
                'three': {
                    path: '/three.js/r58/three.min.js'
                }
            }
        }
    },
    onSuccess: function (e) {      
      for (var i = 0, len = e.data.length; i < len; ++i) {
        if ( e.data[i] === 'moment' ) {
          YUI.add('moment', function (Y){
            Y.moment = moment;
          });
        } else if ( e.data[i] === 'three' ) {
          YUI.add('three', function (Y) {
            Y.THREE = THREE;
          });
        }
      }
    }
}).use('moment', 'three', 'node', function (Y) {
  
    // Check to see if each library is available
    Y.one('pre').append('Date/Time is ' + Y.moment().format('LLL'));
    Y.one('pre').append("<br/>" + 'THREE version: ' + Y.THREE.REVISION); 

});
  </script>

<!--  -->
  <script type="text/javascript" charset="utf-8" src="http://d3js.org/d3.v3.min.js"></script>
  
    <script type="text/javascript">

    var sampleSVG = d3.select("#viz")
        .append("svg")
        .attr("width", 100)
        .attr("height", 100);    

    sampleSVG.append("circle")
        .style("stroke", "gray")
        .style("fill", "white")
        .attr("r", 40)
        .attr("cx", 50)
        .attr("cy", 50)
        .on("mouseover", function(){d3.select(this).style("fill", "aliceblue");})
        .on("mouseout", function(){d3.select(this).style("fill", "white");});
    
    </script>
  <script>
 
  var margin = {top: 20, right: 20, bottom: 30, left: 50},
      width = 960 - margin.left - margin.right,
      height = 500 - margin.top - margin.bottom;
 
  var parseDate = d3.time.format("%d-%b-%y").parse;
 
  var x = d3.time.scale()
      .range([0, width]);
 
  var y = d3.scale.linear()
      .range([height, 0]);
 
  var xAxis = d3.svg.axis()
      .scale(x)
      .orient("bottom");
 
  var yAxis = d3.svg.axis()
      .scale(y)
      .orient("left");
 
  var area = d3.svg.area()
      .x(function(d) { return x(d.date); })
      .y0(height)
      .y1(function(d) { return y(d.close); });
 
  var svg = d3.select("body").append("svg")
      .attr("width", width + margin.left + margin.right)
      .attr("height", height + margin.top + margin.bottom)
    .append("g")
      .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
 
  d3.tsv("/data.tsv", function(error, data) {
    data.forEach(function(d) {
      d.date = parseDate(d.date);
      d.close = +d.close;
    });
 
    x.domain(d3.extent(data, function(d) { return d.date; }));
    y.domain([0, d3.max(data, function(d) { return d.close; })]);
 
    svg.append("path")
        .datum(data)
        .attr("class", "area")
        .attr("d", area);
 
    svg.append("g")
        .attr("class", "x axis")
        .attr("transform", "translate(0," + height + ")")
        .call(xAxis);
 
    svg.append("g")
        .attr("class", "y axis")
        .call(yAxis)
      .append("text")
        .attr("transform", "rotate(-90)")
        .attr("y", 6)
        .attr("dy", ".71em")
        .style("text-anchor", "end")
        .text("Price ($)");
  });
 
  </script>
</body>
</html><commit_msg>Added rough method of graphing candlestick data from finance<commit_after><!DOCTYPE html>
<html>
<head>
<script src="http://yui.yahooapis.com/3.14.1/build/yui/yui.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<style>
 
body {
  font: 10px sans-serif;
}
 
.axis path,
.axis line {
  fill: none;
  stroke: #000;
  shape-rendering: crispEdges;
}
 
.area {
  fill: steelblue;
}
 
</style>

</head>
<body>
  <pre></pre>
  <div id="viz"></div>
  <script>
YUI({
    groups: {
        'cdnjs': {
            base : '//cdnjs.cloudflare.com/ajax/libs',
            modules: {
                'moment' : {
                    path: '/moment.js/2.0.0/moment.min.js'
                },
                'three': {
                    path: '/three.js/r58/three.min.js'
                }
            }
        }
    },
    onSuccess: function (e) {      
      for (var i = 0, len = e.data.length; i < len; ++i) {
        if ( e.data[i] === 'moment' ) {
          YUI.add('moment', function (Y){
            Y.moment = moment;
          });
        } else if ( e.data[i] === 'three' ) {
          YUI.add('three', function (Y) {
            Y.THREE = THREE;
          });
        }
      }
    }
}).use('moment', 'three', 'node', function (Y) {
  
    // Check to see if each library is available
    Y.one('pre').append('Date/Time is ' + Y.moment().format('LLL'));
    Y.one('pre').append("<br/>" + 'THREE version: ' + Y.THREE.REVISION); 

});
  </script>

<!--  -->
  <script type="text/javascript" charset="utf-8" src="http://d3js.org/d3.v3.min.js"></script>
  
    <script type="text/javascript">

    var sampleSVG = d3.select("#viz")
        .append("svg")
        .attr("width", 100)
        .attr("height", 100);    

    sampleSVG.append("circle")
        .style("stroke", "gray")
        .style("fill", "white")
        .attr("r", 40)
        .attr("cx", 50)
        .attr("cy", 50)
        .on("mouseover", function(){d3.select(this).style("fill", "aliceblue");})
        .on("mouseout", function(){d3.select(this).style("fill", "white");});
    
    </script>
  <script>
 
  var margin = {top: 20, right: 20, bottom: 30, left: 50},
      width = 960 - margin.left - margin.right,
      height = 500 - margin.top - margin.bottom;
 
  var parseDate = d3.time.format("%d-%b-%y").parse;
 
  var x = d3.time.scale()
      .range([0, width]);
 
  var y = d3.scale.linear()
      .range([height, 0]);
 
  var xAxis = d3.svg.axis()
      .scale(x)
      .orient("bottom");
 
  var yAxis = d3.svg.axis()
      .scale(y)
      .orient("left");
 
  var area = d3.svg.area()
      .x(function(d) { return x(d.date); })
      .y0(height)
      .y1(function(d) { return y(d.close); });
 
  var svg = d3.select("body").append("svg")
      .attr("width", width + margin.left + margin.right)
      .attr("height", height + margin.top + margin.bottom)
    .append("g")
      .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
 
  d3.tsv("/data.tsv", function(error, data) {
    data.forEach(function(d) {
      d.date = parseDate(d.date);
      d.close = +d.close;
    });
 
    x.domain(d3.extent(data, function(d) { return d.date; }));
    y.domain([0, d3.max(data, function(d) { return d.close; })]);
 
    svg.append("path")
        .datum(data)
        .attr("class", "area")
        .attr("d", area);
 
    svg.append("g")
        .attr("class", "x axis")
        .attr("transform", "translate(0," + height + ")")
        .call(xAxis);
 
    svg.append("g")
        .attr("class", "y axis")
        .call(yAxis)
      .append("text")
        .attr("transform", "rotate(-90)")
        .attr("y", 6)
        .attr("dy", ".71em")
        .style("text-anchor", "end")
        .text("Price ($)");
  });
 
  </script>
  
  <!--  -->
    <script type="text/javascript" src="http://mbostock.github.com/d3/d3.time.js?1.25.0"></script>
	<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>

    <div id="chart"></div>

    <script type="text/javascript">
      var width = 900;
      var height = 500;
       String.prototype.format = function() {
        var formatted = this;
        for (var i = 0; i < arguments.length; i++) {
          var regexp = new RegExp('\\{'+i+'\\}', 'gi');
          formatted = formatted.replace(regexp, arguments[i]);
	}
	return formatted;
      };


      var dateFormat = d3.time.format("%Y-%m-%d");
      var end = new Date();
      var start = new Date(end.getTime() - 1000 * 60 * 60 * 24 * 60);
      var data = [];

      function min(a, b){ return a < b ? a : b ; }
      		 		     
      function max(a, b){ return a > b ? a : b; }    

      function buildChart(data){        
         
          var margin = 50;		   
		  
	  var chart = d3.select("#chart")
		  .append("svg:svg")
		  .attr("class", "chart")
		  .attr("width", width)
		  .attr("height", height);
	  var y = d3.scale.linear()
		  .domain([d3.min(data.map(function(x) {return x["Low"];})), d3.max(data.map(function(x){return x["High"];}))])
		  .range([height-margin, margin]);
	  var x = d3.scale.linear()
		  .domain([d3.min(data.map(function(d){return dateFormat.parse(d.Date).getTime();})),
		  	   d3.max(data.map(function(d){return dateFormat.parse(d.Date).getTime();}))])
		  .range([margin,width-margin]);

          chart.selectAll("line.x")
           .data(x.ticks(10))
           .enter().append("svg:line")
           .attr("class", "x")
           .attr("x1", x)
           .attr("x2", x)
           .attr("y1", margin)
           .attr("y2", height - margin)
           .attr("stroke", "#ccc");

          chart.selectAll("line.y")
           .data(y.ticks(10))
           .enter().append("svg:line")
           .attr("class", "y")
           .attr("x1", margin)
           .attr("x2", width - margin)
           .attr("y1", y)
           .attr("y2", y)
           .attr("stroke", "#ccc");

          chart.selectAll("text.xrule")
           .data(x.ticks(10))
           .enter().append("svg:text")
           .attr("class", "xrule")
           .attr("x", x)
           .attr("y", height - margin)
           .attr("dy", 20)
           .attr("text-anchor", "middle")
           .text(function(d){ var date = new Date(d * 1000);  return (date.getMonth() + 1)+"/"+date.getDate(); });
 
         chart.selectAll("text.yrule")
          .data(y.ticks(10))
          .enter().append("svg:text")
          .attr("class", "yrule")
          .attr("x", width - margin)
          .attr("y", y)
          .attr("dy", 0)
          .attr("dx", 20)		 
          .attr("text-anchor", "middle")
          .text(String);

	chart.selectAll("rect")
	  .data(data)
	  .enter().append("svg:rect")
	  .attr("x", function(d) { return x(dateFormat.parse(d.Date).getTime()); })
          .attr("y", function(d) {return y(max(d.Open, d.Close));})		  
	  .attr("height", function(d) { return y(min(d.Open, d.Close))-y(max(d.Open, d.Close));})
	  .attr("width", function(d) { return 0.5 * (width - 2*margin)/data.length; })
          .attr("fill",function(d) { return d.Open > d.Close ? "red" : "green" ;});

        chart.selectAll("line.stem")
          .data(data)
          .enter().append("svg:line")
          .attr("class", "stem")
          .attr("x1", function(d) { return x(dateFormat.parse(d.Date).getTime()) + 0.25 * (width - 2 * margin)/ data.length;})
          .attr("x2", function(d) { return x(dateFormat.parse(d.Date).getTime()) + 0.25 * (width - 2 * margin)/ data.length;})		    
          .attr("y1", function(d) { return y(d.High);})
          .attr("y2", function(d) { return y(d.Low); })
          .attr("stroke", function(d){ return d.Open > d.Close ? "red" : "green"; })

      }		  


      function appendToData(x){
	if(data.length > 0){
	    return;
        }
        data = x.query.results.quote;
        for(var i=0;i<data.length;i++){
          data[i].timestamp = (new Date(data[i].date).getTime() / 1000);
        }		  
        data = data.sort(function(x, y){ return dateFormat.parse(x.Date).getTime() - dateFormat.parse(y.Date).getTime(); });			
        buildChart(data);		  
      }

      function buildQuery(){
        var symbol = window.location.hash;
        if(symbol === ""){
           symbol = "DIS";
        }
        symbol = symbol.replace("#", "");		  
        var base = "select * from yahoo.finance.historicaldata where symbol = \"{0}\" and startDate = \"{1}\" and endDate = \"{2}\"";
        var getDateString = d3.time.format("%Y-%m-%d");
        var query = base.format(symbol, getDateString(start), getDateString(end));
        query = encodeURIComponent(query);		    
        var url = "http://query.yahooapis.com/v1/public/yql?q={0}&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=appendToData".format(query);
        return url;
      }
      function fetchData(){		  
        url = buildQuery();		  
        scriptElement = document.createElement("SCRIPT");
        scriptElement.type = "text/javascript";
        // i add to the url the call back function
        scriptElement.src = url;
        document.getElementsByTagName("HEAD")[0].appendChild(scriptElement);
      }

      $(document).ready(fetchData);

    </script>
  <!-- yql fetch with YUI -->
  
  <script>
  YUI().use('yql', 'node-base', function (Y) {
      var query = 'select * from local.search where zip="94301" and query="pizza"';
    
      Y.YQL(query, function (response) {
          var ol = Y.Node.create('<ol/>');
              results = response.query.results.Result;
            
          Y.each(results, function (r) {
              ol.append('<li>' + r.Title + ' &mdash; ' + r.Phone + '</li>');
          });
          Y.one('body').append(ol);
      });
  });
  </script>

  <script>
  YUI().use('yql', 'node-base', function (Y) {
      var query = 'use "http://www.datatables.org/yahoo/finance/yahoo.finance.historicaldata.xml" as history; select * from history where symbol = "YHOO" and startDate = "2009-09-11" and endDate = "2010-03-10"';
    
      Y.YQL(query, function (response) {
          var ol = Y.Node.create('<ol/>');
              results = response.query.results.quote;
            
          Y.each(results, function (r) {
              ol.append('<li>' + r.Date + ' &mdash; ' + r.Close + '</li>');
          });
          Y.one('body').append(ol);
      });
  });
  </script>
  
</body>
</html>
{'fraction_non_alphanumeric': 0.20801826223427022, 'fraction_numerical': 0.018404907975460124, 'mean_word_length': 2.019384018953263, 'pattern_counts': {'":': 0, '<': 84, '<?xml version=': 0, '>': 83, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2737081', 'n_tokens_mistral': 5160, 'n_tokens_neox': 4847, 'n_words': 901}