Skip to content

Instantly share code, notes, and snippets.

View j450h1's full-sized avatar

Jas Sohi j450h1

View GitHub Profile
@j450h1
j450h1 / README.md
Last active August 29, 2015 14:19
Liberal Party of Canada - Misleading Chart - Revision

#Original Visualization

This visualization comes from Canada's Liberal Party Website. The message is:

Between 1981 and 2011, Canada’s Real GDP grew by 115%. At the same time the real median income of Canadian families only grew by 15%.

However, Canada's Real GDP Chart's scale is exaggerated as it appears to be 150% growth vs the 15% median income growth. You can see that the Real GDP arrow goes up to the 3rd line (each line is approximately 45-50% since you can fit 3 of those smaller 15% arrows in it (15*3 = 45).

@j450h1
j450h1 / index.html
Last active August 29, 2015 14:22
4 Major Sports Leagues in North America
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Comparing North American Major Sports Leagues by Revenue &amp; Attendance</title>
<link href='http://fonts.googleapis.com/css?family=Lora' rel='stylesheet' type='text/css'>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://dimplejs.org/dist/dimple.v2.0.0.min.js"></script>
<script type="text/javascript">
function draw(data,filter_year) {
@j450h1
j450h1 / index.html
Last active August 29, 2015 14:26 — forked from WilliamQLiu/index.html
D3 Scatterplot (Animations)
<!DOCTYPE html>
<html>
<head>
<!-- Load D3 from site -->
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
</head>
<!-- CSS (Styling) -->
<style type="text/css">
/* Format X and Y Axis */
@j450h1
j450h1 / .Rhistory
Last active September 20, 2015 11:57 — forked from nikolay-shenkov/create_vis.js
Comparing Revenue & Attendance Across Leagues (NHL, NBA, MLB, NFL)
We couldn’t find that file to show.
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Fire up graphlab create"
]
},
{
@j450h1
j450h1 / 0_reuse_code.js
Created December 8, 2015 05:23
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@j450h1
j450h1 / apple_health_load_analysis_R.r
Created September 29, 2016 17:46 — forked from ryanpraski/apple_health_load_analysis_R.r
Load Apple Health Kit export.xml file in R then analyze and visualize Steps Data using R
library(dplyr)
library(ggplot2)
library(lubridate)
library(XML)
#load apple health export.xml file
xml <- xmlParse("C:\\Users\\praskry\\Desktop\\apple_health_data\\export.xml")
#transform xml file to data frame - select the Record rows from the xml file
df <- XML:::xmlAttrsToDataFrame(xml["//Record"])
@j450h1
j450h1 / date_loop.sh
Created October 1, 2016 00:31 — forked from chluehr/date_loop.sh
Bash: Loop over dates
#!/bin/bash
now=`date +"%Y-%m-%d" -d "05/06/2012"`
end=`date +"%Y-%m-%d" -d "05/23/2012"`
while [ "$now" != "$end" ] ;
do
now=`date +"%Y-%m-%d" -d "$now + 1 day"`;
echo $now
done
@j450h1
j450h1 / catfacts.R
Created October 2, 2016 00:41 — forked from jennybc/catfacts.R
Goofing around with the catfacts API
httr::GET("http://catfacts-api.appspot.com/api/facts",
query = list(number = 5)) %>%
httr::content(as = "text", encoding = "UTF-8") %>%
jsonlite::fromJSON()
@j450h1
j450h1 / active-issues.sql
Created April 28, 2017 07:36 — forked from alysonla/active-issues.sql
Queries that power the open source section of the 2016 Octoverse report https://octoverse.github.com/
-- Active issues
-- Count of total active issues in the specified time frame
-- Source: githubarchive public data set via Google BigQuery http://githubarchive.org/
SELECT
COUNT(DISTINCT JSON_EXTRACT_SCALAR(events.payload, '$.issue.id')) AS events_issue_count
FROM (SELECT * FROM TABLE_DATE_RANGE([githubarchive:day.],TIMESTAMP('2015-09-01'),TIMESTAMP('2016-08-31')))
AS events
-- 10,723,492 active issues