Skip to content

Instantly share code, notes, and snippets.

View brandongalbraith's full-sized avatar

B brandongalbraith

  • North America
View GitHub Profile
# gem install crack rest-client fastercsv
require 'rubygems'
require 'crack'
require 'rest_client'
require 'fastercsv'
# To use, get an access token here, by clicking "get access token"
# and checking user.groups in the dialog box
# https://developers.facebook.com/tools/explorer?method=GET&path=209024949216061%2Ffeed
#
@brandongalbraith
brandongalbraith / SelfService-AWSBillingReadOnly.json
Created September 16, 2020 19:33
Enable AWS Billing, Budget, Cost & Usage Reporting Read Only Access to IAM Users
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"aws-portal:View*",
"budgets:View*",
"cur:Describe*",
"purchase-orders:View*"
@brandongalbraith
brandongalbraith / youtube-ls-playlist.sh
Created July 16, 2020 17:48 — forked from zmwangx/youtube-ls-playlist.sh
List video URIs in a YouTube playlist.
#!/usr/bin/env bash
# Takes a YouTube URI to a playlist (fairly liberal, it's fine as long
# as the playlist id can be extracted), and prints a list of URIs in a
# YouTube playlist.
#
# Requires youtube-dl 2014.10.24, tested on youtube-dl
# 2014.11.02.1. Feature subject to change.
youtube-dl -j --flat-playlist "$1" | jq -r '.id' | sed 's_^_https://youtube.com/v/_'
@brandongalbraith
brandongalbraith / url-create.sh
Created May 22, 2020 14:59
Create a .url file on MacOS
# Source: https://superuser.com/questions/689441/how-do-i-create-a-url-file-on-os-x
#!/bin/bash
if [[ $# -le 1 || $# -ge 3 ]] ; then
echo Usage: $0 '<namefile> <url>'
echo
echo Creates '<namefile>.url'.
echo Openning '<namefile>.url' in Finder, under OSX, will open '<url>' in the default browser.
exit 1
fi
@brandongalbraith
brandongalbraith / template.sh
Last active April 16, 2020 16:09
So You're Writing Some Bash #bash
#! /usr/bin/env bash
set -euo pipefail
#!/usr/bin/env ruby
# you must have SoX installed to generate touch tones
# brew install sox
# also, whatever application you run this script from will need to be authorized
# to control your computer, via System Preferences > Privacy > Accessibility
# finally, don't run this with headphones plugged in :)
@brandongalbraith
brandongalbraith / gist:1726b3aec837b3edb025d1f36ff99828
Created November 14, 2019 17:11 — forked from chanks/gist:7585810
Turning PostgreSQL into a queue serving 10,000 jobs per second

Turning PostgreSQL into a queue serving 10,000 jobs per second

RDBMS-based job queues have been criticized recently for being unable to handle heavy loads. And they deserve it, to some extent, because the queries used to safely lock a job have been pretty hairy. SELECT FOR UPDATE followed by an UPDATE works fine at first, but then you add more workers, and each is trying to SELECT FOR UPDATE the same row (and maybe throwing NOWAIT in there, then catching the errors and retrying), and things slow down.

On top of that, they have to actually update the row to mark it as locked, so the rest of your workers are sitting there waiting while one of them propagates its lock to disk (and the disks of however many servers you're replicating to). QueueClassic got some mileage out of the novel idea of randomly picking a row near the front of the queue to lock, but I can't still seem to get more than an an extra few hundred jobs per second out of it under heavy load.

So, many developers have started going straight t

to check if the server works - https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice
stun:
stun.l.google.com:19302,
stun1.l.google.com:19302,
stun2.l.google.com:19302,
stun3.l.google.com:19302,
stun4.l.google.com:19302,
stun.ekiga.net,
stun.ideasip.com,

MicroService Proxy Gateway Solutions

Kong, Traefik, Caddy, Linkerd, Fabio, Vulcand, and Netflix Zuul seem to be the most common in microservice proxy/gateway solutions. Kubernetes Ingress is often a simple Ngnix, which is difficult to separate the popularity from other things.

Github Star Trend:

Github Star History for Kong vs traefik vs fabio vs caddy vs Zuul

This is just a picture of this link from March 2, 2019

Originally, I had included some other solution

import os
import getpass
import boto3
os.environ['AWS_ACCESS_KEY_ID'] = ... # your accounts access key
os.environ['AWS_SECRET_ACCESS_KEY'] = ... # your accounts secret
client = boto3.client("sts")
token = getpass.getpass("Enter MFA token -> ")
# Exchange permanent key/secret for temporary ones