Skip to content

Instantly share code, notes, and snippets.

@schacon
schacon / column_names.sql
Last active April 24, 2023 14:56
getting a list of table column names in BigQuery
View column_names.sql
// first, grab a list of the field names in a table
SELECT STRING_AGG(column_name, ", \n" ORDER BY ordinal_position)
FROM [project_name].[dataset_name].INFORMATION_SCHEMA.COLUMNS
where table_name = 'blah'
group by table_name
@schacon
schacon / docker-compose.yml
Created August 15, 2021 19:15
Docker Compose file for ruby, postgres and redis
View docker-compose.yml
version: '3'
services:
app:
build:
context: ..
dockerfile: .devcontainer/Dockerfile
args:
VARIANT: 2.6
NODE_VERSION: "lts/*"
volumes:
@schacon
schacon / cohort.sql
Last active November 3, 2020 23:38
Cohort Month Base Values for BigQuery
View cohort.sql
select month, months_out from (
select month,
GENERATE_ARRAY(0, DATE_DIFF(CURRENT_DATE(), month, MONTH)) as months,
from UNNEST(
(select
GENERATE_DATE_ARRAY(CAST([STARTING_DATE] AS DATE), CAST(max(date_field) AS DATE),
INTERVAL 1 MONTH) as date
from [SOME_TABLE_WITH_A_DATE_FIELD])
) as month
) CROSS JOIN UNNEST(months) as months_out
View keybase.md

Keybase proof

I hereby claim:

  • I am schacon on github.
  • I am scottchacon (https://keybase.io/scottchacon) on keybase.
  • I have a public key ASAcTJsFnTw59Ncpg1Bax0VQ1yH1B3N2MQaDHsadrT95aAo

To claim this, I am signing this object:

@schacon
schacon / gist:793c8fdea738fd3d04a7
Created December 18, 2014 16:25
crush and resize book images
View gist:793c8fdea738fd3d04a7
#! /usr/bin/env ruby
require 'rubygems'
require 'oily_png'
Dir.glob("book/**/*.png").each do |file|
puts file
image = ChunkyPNG::Image.from_file(file)
p image.width
p image.height
if image.width > 800 || image.height > 800
@schacon
schacon / 0_reuse_code.js
Created December 3, 2013 16:57
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@schacon
schacon / git-http-proto.txt
Created July 26, 2013 22:16
Git HTTP transport protocol documentation
View git-http-proto.txt
HTTP transfer protocols
=======================
Git supports two HTTP based transfer protocols. A "dumb" protocol
which requires only a standard HTTP server on the server end of the
connection, and a "smart" protocol which requires a Git aware CGI
(or server module). This document describes both protocols.
As a design feature smart clients can automatically upgrade "dumb"
protocol URLs to smart URLs. This permits all users to have the
@schacon
schacon / raseij.md
Created May 14, 2013 22:00
Andrew Raseij's PDF speech in 2005
View raseij.md

Welcome to the second annual Personal Democracy Forum. It’s great to see so many familiar faces from last year’s forum, and to greet so many new folks who are here. It seems our blog-ads on Jeff Gannon’s website paid off.

We’re putting on our conference today in cooperation with the Continuing Education and Public Programs at the Graduate Center of the City University of New York. Thank you David Levine and your whole staff here at CUNY, you’ve been fantastic.

I also want to take a moment to thank the terrific and talented PDF staff for putting together a program interesting and provocative enough to get a room full of techies to put down their Berries and Treos for the better part of a day: Hart Hooton, Dawn Barber, Jen Vento, Isabel Walcott, and our executive editor, Micah Sifry. In particular, I’d like to single out Anthony Russomano and Elizabeth Caputo for their tireless efforts to make today a success

And a special thanks to our distinguished group of sponsors: Google, Burson-Marsteller, Echoditto, E

@schacon
schacon / gist:4550891
Created January 16, 2013 20:58
The keyboard shortcuts to know when you hook up your mac to present in keynote (for quicker lightning talks setup)
View gist:4550891
Mirror/unmirror displays: ⌘-F1 or ⌘-fn-1
Switch presenter display: x