Skip to content

Instantly share code, notes, and snippets.

@zacharysyoung
zacharysyoung / README.md
Last active July 25, 2024 19:58
Import rows of data into individual PDFs

Import rows of data into individual PDFs

How to get data like this...

Name Age Street Address City State Zip
Tami 23 123 Main St Anytown Anystate 11111
John 54 456 Second Ave Anytown Anystate 22222
Troy 39 789 Last Cir Anytown Anystate 99999
@zacharysyoung
zacharysyoung / multiple_emails.js
Last active April 23, 2021 20:04
Find and deal with cells in the spreadsheet that have multiple email addresses
/*
You can run this in Chrome by:
1. going to View > Developer > Developer Tools
2. find the "Console" tab
3. copy all the stuff below in one chunk, and paste into the console
4. hit <Enter>
After that you can modify a line by copying it and pasting onto new a line and hitting <Enter> to re-run that line
*/
@zacharysyoung
zacharysyoung / README.md
Last active January 22, 2021 09:39
NC and PRT files (#BelieveInYourself #NeverGiveUp #Grep)

OMG, I was feeling so low about an hour ago:

  • I was looking at a super-slick shell script written by a pro (I'll call this person "Ace") using tools I hadn't seen before
  • The structure of the NC file was even more daunting at first blush than the PRT files—the PRT was massive, but it was flat
  • A basic idea like the values being the same between the PRT and NC files was eluding me

And I was about to email you this message:

So, here's my analysis of what's going on...

This shit is so far over my head!

@zacharysyoung
zacharysyoung / commands.sh
Last active June 16, 2021 04:08
Parsing PRT file
#!/bin/bash
grep 'INSTANT CH4' *.PRT | \ # scan all files (*.PRT) and filter each file by the text "INSTANT CH4"
awk ' NR % 2 == 1 { print; } ' | \ # there are two different datasets per file with your variables, this takes the
# 'INSTANT CH4' line from the first dataset
cut -c 1-7,67-76 | \ # cut out everything *but* the filename/year (first 7 characters) and the column
# for the data point you care about (characters 67 to 76)
sed -E 's/ +/,/' \ # `cut` takes year and data columns and joins them with a space, `sed` replaces
# the space with a comma for CSV
> INSTANT_CH4.csv # save the output to a CSV file
@zacharysyoung
zacharysyoung / Dice.swift
Last active August 22, 2020 05:27
Developing SwiftUI chops
//
// ContentView.swift
// Dice2
//
// Created by Zach Young on 8/17/20.
// Copyright © 2020 Zach Young. All rights reserved.
//
import SwiftUI
@zacharysyoung
zacharysyoung / make.jq
Last active April 19, 2020 05:23
jq scripts for transforming JSON output into shell scripts
"#!/bin/zsh",
"BASE_URL=https://pivotaltracker.com",
(. [] |
.id as $sid | (
"\nmkdir \($sid)",
(
.comments[].file_attachments[] |
"curl --location -s -H \"X-TrackerToken: $TOKEN\" \"$BASE_URL\(.download_url)\" > \($sid)/\(.id)_\(.filename)"
)
)
#!/usr/bin/env python
"""
Permute the characters of an encoding space.
"""
import math
import sys
def permute_arbitrary(chars, _len, arr, s):
"""Permutes an arbitrary encoding space, each permutation being a string of chars of length _len"""
@zacharysyoung
zacharysyoung / wiki_revs.py
Last active August 26, 2019 00:28
Get revisions for a Wiki article, in this case, 'Once Upon a Time in Hollywood'
"""
I got really interested in how many edits 'Once Upon a Time in Hollywood' got after
reading about the contentious issue of whether or not the Plot section should include
information deemed to be a spoiler, and the kinda-heated debate on the Talk page.
This gist also serves as my own documentation for using the WikiMedia query/revisions API.
"""
import json
import pickle
import pprint
#!/bin/bash
bin/godoc -http "localhost:6060" -index -index_files bin/idx -v > godoc.log 2>&1 &
open "http://localhost:6060/"
bin/tour > tour.log 2>&1 &
docPid=$(ps | grep godoc | grep -v grep | awk '{print $1}')
tourPid=$(ps | grep tour | grep -v grep | awk '{print $1}')
echo "#!/bin/bash" > kill-learn.sh
@zacharysyoung
zacharysyoung / permute.py
Last active June 30, 2019 04:57
Still playing around with this silly recursive function for permutating a positional notation
def permute(n, chars='01', limit=128, start=0):
appended = 0
counter = 0
def f(s, a):
nonlocal appended
nonlocal counter
if appended == limit:
return a
if len(s) == n: