Skip to content

Instantly share code, notes, and snippets.

View zacharysyoung's full-sized avatar

Zach Young zacharysyoung

View GitHub Profile
@zacharysyoung
zacharysyoung / make_test_gmails.py
Last active May 24, 2019 17:30
Permutate punctuation for test GMails
#!/usr/bin/env python
import sys
"""
Got the idea from https://learn.lytics.com/understanding/product-docs/lytics-javascript-tag/testing-and-verification#testing-audiences
Given an input of "test", makes:
t.e.s.t.@gmail.com
t.e.s.t@gmail.com
t.e.st.@gmail.com
@zacharysyoung
zacharysyoung / make_test_gmails.go
Last active May 27, 2019 08:47
Permutate punctuation (dots) for test email name
package main
/*
Got the idea from https://learn.lytics.com/understanding/product-docs/lytics-javascript-tag/testing-and-verification#testing-audiences
Given an input of "test", makes:
t.e.s.t.@gmail.com
t.e.s.t@gmail.com
t.e.st.@gmail.com
@zacharysyoung
zacharysyoung / a_main.go
Last active July 27, 2020 21:35
'The Go Programming Language', Exercise 1.4
// Exercise 1.4 from 'The Go Programming Language', by A Donovan and
// B Kernigham
//
// Zach Young
// 27 May, 2019
//
//Dup2 prints the count and text of lines that appear more than once
//in the input. It reads from stdin or from a list of named files.
package main
@zacharysyoung
zacharysyoung / astro_circf.py
Last active June 25, 2019 20:01
Prints a circumference of astronomical sizes in miles-feet-inches
# Inspired by:
# 'How many digits of pi do we really need?'
# (https://www.jpl.nasa.gov/edu/news/2016/3/16/how-many-decimals-of-pi-do-we-really-need/)
#
# I wanted to see for myself that the difference between 15 digits and 16
# digits amounted to only half of an inch at the scale of Voyager 1's
# distance of ~12.5 billion miles
from decimal import Decimal, getcontext
@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:
#!/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 / 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
#!/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 / 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)"
)
)
@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