Skip to content

Instantly share code, notes, and snippets.

Brian J Brennan brianloveswords

View GitHub Profile
View concurrency-in-bash.sh
#!/usr/bin/env bash
function example() {
set -o errexit
set -o nounset
## only needed for the example
local worktime=0
# how many concurrent operations to perform
@brianloveswords
brianloveswords / 1-README.md
Last active Nov 26, 2019
BigQuery Cost Estimator
View 1-README.md

BigQuery Cost Estimator

Get an estimate of how much a query is going to cost before you run it.

Instructions

  1. Create a new bookmark with the contents of 2-bookmarklet as the URL.
  2. Whenever you open a new BQ session, click the bookmarklet to attach the observer. You only have to do it once per session.
View file.js
function addH1() {
document.body.innerHTML += '<h1>okay!</h1>';
}
// this lets callers from `file.js` through to the original version of
// innerHTML but not other callers
(function(){
const innerHTMLDesc = Object.getOwnPropertyDescriptor(Element.prototype, 'innerHTML');
Object.defineProperty(Element.prototype, 'innerHTML', {
get() {
@brianloveswords
brianloveswords / mkbin
Last active Oct 3, 2018
mkbin: a shell script that makes shell scripts
View mkbin
#!/bin/bash
# mkbin: create a new shell script and open the editor
mode="create"
if [ "$1" = "-e" ] || [ "$1" = "--edit" ]; then
mode="edit"
shift
fi
View !noncrono.org

Identifying Non-Chronological Tweets In Timeline

[jump to complete source]

There are two stages to this:

  1. identify initially loaded non-chrono tweets
  2. identify newly loaded non-chrono tweets as user scrolls
View gif-from-tweet.md

gif-from-tweet

There are so many great GIFs out there and I want to have copies of them. Twitter makes that harder than it should be by converting them to MP4 and not providing access to the source material. To make it easier, I made a bash pipeline that takes a tweet URL and a filename, extracts the MP4 from that tweet and uses ffmpeg to convert back to GIF.

Dependencies

  • ffmpeg
    • macOS: brew install ffmpeg
    • Ubuntu/Debian: apt install ffmpeg
View celebrate.go
/// Print out 140 characters of random celebratory emoji.
package main
import (
"fmt"
"math/rand"
"time"
)
@brianloveswords
brianloveswords / follower-csv.js
Last active Nov 3, 2017
Copy a CSV of your followers to your clipboard
View follower-csv.js
// put this in the console on https://twitter.com/<username/followers
timer = setInterval(() => window.scrollTo(0, document.body.scrollHeight), 100);
// wait until the document stops scrolling...
clearInterval(timer);
// this will copy the CSV to your clipboard
copy(
@brianloveswords
brianloveswords / partial-package.json
Created Sep 18, 2017
TypeScript autobuild and copy to clipboard. Useful for developing stuff where you can't actually access the content directly in a text editor (e.g. tampermonkey)
View partial-package.json
{
"scripts": {
"build": "tsc && npm run post-build",
"watch": "tsc-watch --onSuccess 'npm run post-build'",
"post-build": "rollup build/index.js --o build/bundle.js --f iife && cat src/prelude.js build/bundle.js | (pbcopy && osascript -e 'display notification \"Script copied to clipboard\" with title \"Script Builder\"' || echo 'copied script to clipboard')"
}
}
View keybase.md

Keybase proof

I hereby claim:

  • I am brianloveswords on github.
  • I am brianloveswords (https://keybase.io/brianloveswords) on keybase.
  • I have a public key ASBtQroGJWStLytKo1YW1Jom-wCpZdwvzrP8cn0N0auwjQo

To claim this, I am signing this object:

You can’t perform that action at this time.