Skip to content

Instantly share code, notes, and snippets.

View benjaminestes's full-sized avatar

Benjamin Estes benjaminestes

View GitHub Profile
@benjaminestes
benjaminestes / semidifference.sql
Last active April 15, 2023 03:49
Semidifference or semijoin operations in BigQuery
#standardSQL
WITH
a AS (
SELECT
num
FROM
UNNEST(GENERATE_ARRAY(1, 6)) AS num),
b AS (
SELECT
num
@benjaminestes
benjaminestes / bq-pi.sql
Last active August 5, 2017 15:01
Estimate pi with BigQuery
#standardSQL
WITH
trials AS (
SELECT
rand() AS x,
rand() AS y
FROM
UNNEST(GENERATE_ARRAY(1, POW(2, 19)))),
results AS (
SELECT
@benjaminestes
benjaminestes / fix_utf.py
Last active November 18, 2022 06:43
Convert a UTF-16 file to UTF-8
#!/usr/bin/env python
# Invocation:
# ./fixutf.py input_file.csv
#
# Outputs to
# utf8-[input_file.csv]
import sys
@benjaminestes
benjaminestes / .block
Last active November 9, 2016 01:33
Line chart
license: mit
@benjaminestes
benjaminestes / cssPropertyToCamelCase.js
Created September 8, 2016 03:58
Recursively generate camel-cased CSS property names.
const toCamelCase = text => {
if (!text.length) return '';
const re = /\-(\w)/g;
const match = re.exec(text);
if (match) {
return text.slice(0, match.index) + match[1].toUpperCase() + toCamelCase(text.slice(re.lastIndex));
}
return text;
};
@benjaminestes
benjaminestes / .block
Last active November 9, 2016 01:48
Column chart
license: mit
var imgNodes = document.getElementsByClassName('speakerPic');
var list;
for (var i = 0; i < imgNodes.length; i++) {
list = list + imgNodes[i].getAttribute('src') + '\n';
}
list.trim();