Skip to content

Instantly share code, notes, and snippets.

View ryantuck's full-sized avatar
🤙
chillin'

Ryan Tuck ryantuck

🤙
chillin'
View GitHub Profile
@ryantuck
ryantuck / looker_content_validator.py
Last active October 31, 2019 18:56
Script to extract content from Looker Content Validator HMTL table
# this is probably less elegant than just using the API to do this
# https://docs.looker.com/reference/api-and-integration/api-reference/v3.1/content#validate_content
# largely copied from https://stackoverflow.com/a/44275458
import csv
from bs4 import BeautifulSoup
# find the table where all the data lives via 'inspect element' or whatever
# and save it into a file that we read here.
dot -Kfdp -Nfontname=Courier -Nfontsize=10 -Efontname=Courier -Efontsize=10 -T{fmt} {dot_filepath} -o {output_filepath}
@ryantuck
ryantuck / query.yml
Created October 1, 2019 21:27
Idea for writing a SQL query in yaml
from:
base: orders
joins:
- name: items
type: inner
on: items.order_id = orders.id
- name: products
type: inner
on: products.id = items.product_id
- name: shipments
"""
TruffleHog Results Parsing
Designed to operate on the output of trufflehog's json output:
$ trufflehog --json <my_repo> > my_output.json
Expects a `trufflehog_output.json` file, and a `trufflehog_whitelist.yml` file.
Whitelist config file should look like:
  • let's try outlines
    • here's something that i'd love to ensure gets wrapped oh wow, v cool
    • how about this?
@ryantuck
ryantuck / todo.md
Last active January 20, 2019 14:07

todo

  • eat
  • do something else
import random
import time
import multiprocessing as mp
def sleep_random(n):
sleep_seconds = random.randint(0, 3)
print(f'sleeping for {sleep_seconds} seconds')
# randomly fail
x = 5 / sleep_seconds
@ryantuck
ryantuck / git_squash_example.md
Created November 29, 2018 15:41
How to squash commits, for when you forget

How to squash commits, for when you forget:

• ~/src $$$ mkdir git-stuff
• ~/src $$$ cd git-stuff/
• ~/src/git-stuff $$$ git init
Initialized empty Git repository in /Users/ryan.tuck/src/git-stuff/.git/
• ~/src/git-stuff $$$ git status
On branch master
@ryantuck
ryantuck / sql_load_generator.py
Created November 27, 2018 23:51
Configurable python code to generate random SQL tables and indexes using pure SQL.
import json
import random
def _gen_ids(b,e):
return f'generate_series({b}, {e})::bigint'
def _gen_float():
return 'random()'
@ryantuck
ryantuck / split_csvs.py
Created March 22, 2018 23:28
splitting csvs in python
import csv
import os
source_filename = 'all.csv'
records_per_file = 1000
target_file_prefix = 'target/split'
with open(source_filename, 'r') as source:
reader = csv.reader(source)