Skip to content

Instantly share code, notes, and snippets.

View tswast's full-sized avatar

Tim Sweña (Swast) tswast

View GitHub Profile
@tswast
tswast / README.md
Last active December 10, 2015 05:48 — forked from mbostock/.block
Multi-Series Line to Stacked Area Chart Transition

This stacked area chart is constructed from a TSV file storing the market share of several popular web browsers over the last year. Data is from Clicky Web Analytics. The chart employs conventional margins and a number of D3 features:

@tswast
tswast / designer.html
Last active August 29, 2015 14:11
designer
<link rel="import" href="../core-animated-pages/core-animated-pages.html">
<link rel="import" href="../core-animated-pages/transitions/hero-transition.html">
<link rel="import" href="../core-animated-pages/transitions/cross-fade.html">
<link rel="import" href="../core-animated-pages/transitions/slide-down.html">
<link rel="import" href="../core-animated-pages/transitions/slide-up.html">
<link rel="import" href="../core-animated-pages/transitions/tile-cascade.html">
<polymer-element name="music-demo">
<template>
@tswast
tswast / convert.py
Created September 15, 2016 00:00
Converting CREATE table SQL from MySQL to SQLite
# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@tswast
tswast / cleannone.py
Created October 21, 2016 19:07
Remove None and NoneType from parameter types in docstrings.
# Copyright 2016 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@tswast
tswast / nyc-citibike-groups-destinations.sql
Last active September 13, 2017 15:26
Most popular Citibike destinations for groups.
#standardSql
SELECT
group_trips / (single_trips + group_trips) AS percent_groups,
single_trips + group_trips AS total_trips,
q.end_station_id AS end_station_id,
stations.name AS name,
stations.latitude AS latitude,
stations.longitude AS longitude
FROM (
SELECT
#standardSQL
SELECT
MAX(max) AS highest_high,
stn,
wban
FROM `bigquery-public-data.noaa_gsod.gsod*`
WHERE max != 9999.9
GROUP BY stn, wban
ORDER BY highest_high DESC
@tswast
tswast / count-names.sql
Created March 3, 2017 22:23
Count the number of people with each name in the [USA Names public dataset](https://cloud.google.com/bigquery/public-data/usa-names).
#standardSQL
SELECT
name,
name_total,
SUM(name_total) OVER(ORDER BY name ASC) AS name_cumulative
FROM (
SELECT
name,
SUM(number) AS name_total
FROM
@tswast
tswast / usa-names-conditional-probabilities.sql
Created April 4, 2017 19:29
USA Names Conditional Probabilities
#standardSQL
SELECT
a.name AS name,
a.state AS state,
a.gender AS gender,
a.year AS year,
a.number AS number,
(a.number / b.total_number) AS name_frequency
FROM
`bigquery-public-data.usa_names.usa_1910_current` a
@tswast
tswast / typical-usa-names-by-state.sql
Created April 4, 2017 19:49
Typical USA Names by State
#standardSQL
SELECT
a.name AS name,
a.state AS state,
a.gender AS gender,
a.year AS year,
a.number AS number,
a.name_frequency AS name_frequency
FROM
`usa_names.names_conditional_probabilities` a
@tswast
tswast / 0-tinyarchive.py
Last active May 20, 2018 16:10
Create a self-contained HTML archive of your TinyLetter newsletter
# coding: utf-8
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#