Skip to content

Instantly share code, notes, and snippets.

View williamtsoi1's full-sized avatar
💭
I may be slow to respond.

William Tsoi williamtsoi1

💭
I may be slow to respond.
View GitHub Profile
@williamtsoi1
williamtsoi1 / auth.js
Last active September 28, 2023 01:43
Sample API endpoint to show how to do SSO embedding in Looker
import { createSignedUrl } from "../../../helpers/auth_utils";
import Cors from "cors";
import user from "./demo_user.json";
// Initializing the cors middleware
const cors = Cors({
origin: "*",
methods: ["GET"],
});
@williamtsoi1
williamtsoi1 / LookerEmbedDashboard.js
Created July 7, 2023 03:34
Show how filters for a Looker embedded dashboard can be retrieved and used outside the immediate react component
import React, { useEffect, useRef } from "react";
import { LookerEmbedSDK } from "@looker/embed-sdk";
const LookerEmbedDashboard = ({callback}) => {
const [dashboardEmbedded, setDashboardEmbedded] = React.useState(false);
const dashboardRef = useRef(false);
useEffect(() => {
if (dashboardRef.current) return;
dashboardRef.current = true;
makeDashboard();
@williamtsoi1
williamtsoi1 / bigquery_slot_utilization.sql
Created May 3, 2023 03:13
BigQuery Slot Utilization (By Organization)
-- This script will look into your GCP organization's BigQuery usage and provide slot utilization by buckets and minutes.
-- The data gathered will be for the last month (720 hours prior to end_date).
-- Note that this script does not gather slot utilization from existing BigQuery reservations. This is only for on-demand slot utilization.
--
-- Required permissions:
-- You need to have the bigquery.jobs.listAll permission for the GCP organization in order to run this query.
-- Details here: https://cloud.google.com/bigquery/docs/information-schema-jobs-timeline-by-organization#required_permissions
--
-- Instructions:
-- 1. Modify the end_date variable to match the month period that you wish to analyze
@williamtsoi1
williamtsoi1 / bootstrap.sh
Last active December 19, 2020 16:41
bootstrap script for my linux mint install
#!/bin/sh
# need to run this whole script as root
# remove nosnapd
rm -f /etc/apt/preferences.d/nosnap.pref
# add ppas
apt-add-repository -y ppa:fish-shell/release-3
add-apt-repository -y ppa:oibaf/graphics-drivers
@williamtsoi1
williamtsoi1 / lake-s3-object-take-ownership.js
Last active September 1, 2020 07:48
a lambda function to automatically take ownership of any objects written into an s3 bucket. Inspired by https://gist.github.com/joech4n/953c1cd6a36698c5d120
console.log('Loading event');
var aws = require('aws-sdk');
var s3 = new aws.S3({apiVersion: '2006-03-01'});
var sqs = new aws.SQS({apiVersion: '2012-11-05'});
exports.handler = function(event, context, callback) {
s3.listBuckets(function(err,data) {
if (err) {
console.log('ERROR: Problem getting list of buckets. This should have something to do with incorrect IAM permissions for the lambda.');
errorMessage = 'ERROR: Error from S3: '+err;
### Keybase proof
I hereby claim:
* I am williamtsoi1 on github.
* I am williamtsoi (https://keybase.io/williamtsoi) on keybase.
* I have a public key whose fingerprint is 11CA E842 C8C9 32DD 8AD0 43D1 D9AB FD09 3C03 E987
To claim this, I am signing this object: