Skip to content

Instantly share code, notes, and snippets.

Avatar

Tim Swast tswast

View GitHub Profile
@tswast
tswast / generate_avro.py
Created Jul 23, 2020
Generate Random Data for Google Cloud Spanner Import
View generate_avro.py
# Copyright 2020 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
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@tswast
tswast / bigquery_github.py
Created Sep 12, 2018 — forked from crwilcox/bigquery_github.py
Scan GitHub using BigQuery
View bigquery_github.py
from google.cloud import bigquery
import json
GITHUB_USERNAME = 'crwilcox'
START_DATE = "2018-03-05"
END_DATE = "2018-08-31"
client = bigquery.client.Client()
query = f"""SELECT repository, type, event AS status, COUNT(*) AS count
View keybase.md

Keybase proof

I hereby claim:

  • I am tswast on github.
  • I am timswast (https://keybase.io/timswast) on keybase.
  • I have a public key ASCPBmBWMaMiH6y4FPDP2Z_EbU9q5ASgdl3zoJAXrM5fGwo

To claim this, I am signing this object:

@tswast
tswast / 0-tinyarchive.py
Last active May 20, 2018
Create a self-contained HTML archive of your TinyLetter newsletter
View 0-tinyarchive.py
# 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
#
View typical-usa-names-by-state.sql
#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 / usa-names-conditional-probabilities.sql
Created Apr 4, 2017
USA Names Conditional Probabilities
View usa-names-conditional-probabilities.sql
#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 / count-names.sql
Created Mar 3, 2017
Count the number of people with each name in the [USA Names public dataset](https://cloud.google.com/bigquery/public-data/usa-names).
View count-names.sql
#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
View highest-high.sql
#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 / nyc-citibike-groups-destinations.sql
Last active Sep 13, 2017
Most popular Citibike destinations for groups.
View nyc-citibike-groups-destinations.sql
#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
@tswast
tswast / cleannone.py
Created Oct 21, 2016
Remove None and NoneType from parameter types in docstrings.
View cleannone.py
# 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,