Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
computering

Brian J Brennan brianloveswords

💭
computering
View GitHub Profile
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
@brianloveswords
brianloveswords / git-obliterate
Last active Apr 8, 2022
git-obliterate: for removing sensitive files you may have committed from the entire history of the project.
View git-obliterate
#!/bin/bash
file=$1
test -z $file && echo "file required." 1>&2 && exit 1
git filter-branch -f --index-filter "git rm -r --cached $file --ignore-unmatch" --prune-empty --tag-name-filter cat -- --all
git ignore $file
git add .gitignore
git commit -m "Add $file to .gitignore"
View alarm.html
<audio id="alarm" src="alarm.ogg" controls></audio>
<script>
const alarmElement = document.getElementById('alarm');
const alarmTimes = [
new Date('2015-11-13 07:00 -0500'),
new Date('2015-11-13 08:00 -0500'),
new Date('2015-11-13 08:30 -0500'),
];
function playAlarm() {
@brianloveswords
brianloveswords / get-http-codes.sh
Created Aug 26, 2011
bash: get http response codes for a list of URLs
View get-http-codes.sh
#!/bin/bash
# from http://www.hilarymason.com/blog/bash-get-http-response-codes-for-a-list-of-urls/
while read line
do
echo $(curl --write-out %{http_code} --silent --output /dev/null $line)
done <$1
@brianloveswords
brianloveswords / 1-README.md
Last active Apr 26, 2021
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 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
View cursed.js
function cursedPromise() {
return new Promise(resolve => {
if (Math.random() > 0.5) resolve();
});
}
async function main() {
await cursedPromise();
console.log("after await");
return "ok";
View monitor.js
var is_setup = null;
var hash_col = null;
var user_col = null;
var continue_execution = function(){
if ( !(is_setup && hash_col && user_col) ) return false;
sys.puts('setup and found collections');
start_stream();
return true;
};
View what's up with restify?.js
const restify = require('restify')
const server = restify.createServer({
name: 'next test',
version: '1.0.0'
});
server.get('/', function (req, res, next) {
console.log('nexting')
req.whatever = Date.now()
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() {