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 / 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)
@ryantuck
ryantuck / problem.csv
Created March 6, 2018 17:23
1000-piece puzzle problem and solution
id edge_top edge_right edge_bottom edge_left orientation row col
2917 tab-7750469 tab-17732443 tab-4722623 tab-8858929
5881 tab-38067713 blank-29069783 blank-37044419 tab-16331537
6199 tab-36443921 tab-30988801 tab-21950659 tab-37745711
4217 tab-11213003 tab-1463299 blank-8505689 tab-27330377
1019 blank-4370491 tab-7873813 tab-3761129 blank-8069461
6337 tab-46570613 tab-34099397 blank-37077787 blank-3035423
3517 blank-8901527 blank-7867529 tab-23279023 tab-18671753
7069 tab-34433099 blank-39027949 tab-43976249 blank-6029857
7691 blank-26664697 tab-51675829 tab-60966557 tab-2407283
@ryantuck
ryantuck / sql_201.sql
Created March 1, 2018 22:14
Notes from SQL 201
-- let's check what our table looks like
-- without bringing in everything
select * from email.sends limit 10;
select * from email.opens limit 10;
-- how many records are in the table?
select count(*)
from email.sends
limit 10;