Skip to content

Instantly share code, notes, and snippets.

View drench's full-sized avatar

Daniel Rench drench

View GitHub Profile
@drench
drench / neoyow.sh
Last active January 27, 2019 14:37
Neo-Yow!
#!/bin/sh
yow_url=https://raw.githubusercontent.com/shlomif/fortune-mod/eeea80856c35f1e4487eed3e59829539eb12c07b/fortune-mod/datfiles/zippy
all_yows() {
test -e './yow.dat' || curl --silent $yow_url | sed -E 's#(.)%#\1\\%#g' > yow.dat
cat yow.dat
}
total_yow_count() {
@drench
drench / zipcast
Created September 29, 2018 21:44
#!/bin/sh
dir=$(mktemp -d)
unzip "$1" -d "$dir"
for f in $dir/*.m4a; do
echo "converting $f to mp4…"
afconvert -f mp4f "$f"
done
@drench
drench / tw-get-home_timeline.sh
Last active February 26, 2018 03:01
Fetch your twitter timeline, one JSON blob per file
#!/bin/sh
# https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-home_timeline
since_id() {
if [ -r './.since_id' ]; then
cat './.since_id'
else
echo 100000
fi
}
@drench
drench / ytjson
Created January 22, 2018 00:13
A shell script to fetch metadata for Y*uTube videos
#!/bin/sh
#
# Given a Y*uTube video ID, this grabs JSON metadata from publically available
# HTML. No API!
#
# Requires:
# * curl
# * node
# * pup https://github.com/ericchiang/pup
#
@drench
drench / hourly-timeline-tweet-frequency
Last active January 16, 2018 02:56
Given an array of tweet objects, this generates a CSV of frequency per hour. IOW: when is this user awake?
#!/bin/sh
TZ=UTC jq -rc '
.[] |
. + {
hour: .created_at | strptime("%a %b %d %T %z %Y")[3],
quoted_status: .quoted_status
} |
{ hour: .hour } +
if .retweeted_status|type == "object" then
@drench
drench / tw-get-user_timeline.sh
Last active January 10, 2018 03:57
Twitter: Get user timeline
#!/bin/sh
# This grabs all tweets from the given user (or as many as Twitter will give
# you; the docs say 3200) and stores them as a JSON array in the file
# ${screen_name}-timeline.json in the current directory.
#
# It requires jq and twurl, and assumes you have set up twurl with working API
# credentials.
#
# It doesn't clean up after itself, so make sure the current directory is clear
# of any files matching ${screen_name}-*.json before running.
#!/bin/sh
#
# usage: tw-get-likes twitter_username
#
# Requires:
# * twurl
# * jq
#
# The API is rate-limited to 75 calls in a 15 minute window
# but this doesn't handle rate limit error returns. Who has 15k likes anyway?
#!/usr/bin/env ruby
# https://www.meetup.com/ChicagoRuby/events/241147344/
class Grid
attr_accessor :board, :size
def initialize(size)
@size = size
@board = Array.new(size) { Array.new(size, ". ") }
end
@drench
drench / tw-get
Last active May 20, 2017 21:30
A shell script to fetch your twitter followers and followings. Requires https://github.com/twitter/twurl and https://github.com/stedolan/jq
#!/bin/sh
case "$1" in
followers)
api_endpoint="/1.1/followers/list.json"
output_prefix="followers"
;;
following)
api_endpoint="/1.1/friends/list.json"
@drench
drench / nucore-merge-describer.sh
Created January 17, 2017 20:35
This generate a list of PR merges between `develop` and the current branch in markdown, suitable for pasting into a PR
#!/bin/sh
git log develop.. | egrep '\(#\d+\)$' | while read LINE; do
pr=$(echo $LINE | sed -E 's/^.+\(#//' | sed -E 's/\)$//')
desc=$(echo $LINE | sed -E 's/ *\(#[0-9]+\)$//')
echo "$pr\t$desc"
done | sort -n |
while read LINE; do
pr=$(echo $LINE | cut -d' ' -f1)