Skip to content

Instantly share code, notes, and snippets.

View troyharvey's full-sized avatar
:octocat:

Troy Harvey troyharvey

:octocat:
View GitHub Profile
@troyharvey
troyharvey / direnv.md
Created June 28, 2022 23:06
Automatically load .env files
@troyharvey
troyharvey / README.md
Created May 29, 2020 03:17
Transform the opawg Podcast User Agent list into a jsonl file for BigQuery
  1. Generate a jsonl file with all the Podcast User Agents.

     node agents.js
    
  2. Use the BigQuery console to create a table and load the podcast-user-agents.jsonl file into the new table.

@troyharvey
troyharvey / README.md
Last active April 25, 2024 23:18
GitHub Action for running the getdbt.com dbt CLI with BigQuery

Using GitHub Actions to run dbt

This example shows you how to use GitHub Actions to run dbt against BigQuery.

  1. Follow the instructions on getdbt.com for installing and initializing a dbt project.

  2. Copy this action (dbt.yml) into the workflows directory.

     mkdir .github
     mkdir .github/workflows
    

cp ~/Downloads/dbt.yml .github/workflows/

@troyharvey
troyharvey / ReEncryptDataCommand.php
Created September 18, 2019 19:26
Encrypt data after changing the APP_KEY
<?php
namespace App\Console\Commands;
use DB;
use Illuminate\Encryption\Encrypter;
use Illuminate\Support\Str;
use Illuminate\Console\Command;
class ReEncryptData extends Command
@troyharvey
troyharvey / my-git-workflow.md
Last active June 28, 2022 22:20
A brief description of how I like to use git

My git Workflow

This is just one way of using git/GitHub. But I have been using this same basic flow for 10 years and I rarely have trouble.

  1. Checkout the main branch

     git checkout main
    
  2. Pull the most recent version of main from GitHub

@troyharvey
troyharvey / airflow_redshift.py
Created September 21, 2018 19:43
An Airflow operator that translates a Postgres table definition into a Redshift CREATE TABLE statement.
class CreateRedshiftTableFromSchemaOperator(BaseOperator):
"""
Create Redshift Table from schema file.
:param redshift_conn_id Airflow Redshift Connection ID
:type redshift_conn_id string
:param schema Redshift schema
:type schema string
:param table Redshift table
:type table string
@troyharvey
troyharvey / gephi-graph-streaming-cayley.md
Last active August 1, 2018 13:36
Using the Gephi Graph Streaming Plugin with Cayley

Cayley is an open-source graph inspired by the graph database behind Freebase and Google's Knowledge Graph. Gephi is an open-source graph visualization tool. The Graph Streaming plugin for Gephi allows you to visualize a Cayley graph or a stream of real-time changes to a Cayley graph.

  1. Install Cayley

     brew install cayley
    
  2. Start Cayley with the Movie Data sample

@troyharvey
troyharvey / fromStorageUrl.js
Created July 21, 2018 21:32
Extract bucket and path from Google Cloud Storage URL
/**
* Convert Google Cloud Storage object url into an object with bucket and file path.
*/
function fromStorageUrl(url) {
var tokens = RegExp('https://storage.googleapis.com/(.+?)/(.+)','g').exec(url);
if (tokens === null) throw "Invalid Google Cloud Storage url.";
return {
'bucket': tokens[1],
'file': tokens[2]
@troyharvey
troyharvey / .gitlab-ci.yml
Last active January 8, 2024 00:38
Deploy Google Cloud Functions: GitLab CI/CD Pipeline Config File
# Update Jan 2024
# Deploying Cloud Functions is much simpler than it was 6 years ago.
# I'm leaving the gist in it's original 2018 state for now,
# but skip the the recent comments below for a simpler solution.
variables:
GCP_ZONE: us-central1-a
stages:
- npm-install
@troyharvey
troyharvey / backpacking-checklist-cool.md
Last active May 25, 2022 11:34
3 Night Cool Weather Backpacking Trip Checklist