Skip to content

Instantly share code, notes, and snippets.

View aspotton's full-sized avatar

Adam Spotton aspotton

View GitHub Profile
@aspotton
aspotton / record_with_audio.sh
Created October 14, 2020 14:35
Bash script to record my second monitor with sound output mixed with USB microphone input. Can be used to record Zoom, Google Meet, or other calls with full audio even if you don't have the record permission.
#!/bin/bash
# Records only speaker output
#/usr/bin/ffmpeg -f x11grab -y -r 15 -s 1920x1080 -i :1.0+1920,0 -f pulse -i default -vcodec mpeg4 -qscale 0 ~/video.mp4
# Records speaker output and webcam microphone input together (Pulse audio)
# Find microphone: pacmd list-sources
# Test recording: ffmpeg -f pulse -ac 2 -i alsa_input.usb-046d_0821_AE9295A0-00.analog-stereo test.mp4
/usr/bin/ffmpeg -f x11grab -y -r 15 -s 1920x1080 -i :1.0+1920,0 -f pulse -i alsa_output.usb-DisplayLink_Plugable_UD-ULTCDL_10027015-02.analog-stereo.monitor -f pulse -ac 2 -i alsa_input.usb-046d_0821_AE9295A0-00.analog-stereo -filter_complex "[1:0][2:0]amix=inputs=2:duration=shortest" -vcodec mpeg4 -qscale 0 ~/video.mp4
@aspotton
aspotton / amazon_ecs_entry_for_boto_v2_support.sh
Created April 8, 2020 20:51
Support using boto v2 in a task under Amazon ECS
#!/bin/bash
# Boto v2 doesn't use the AWS_CONTAINER_CREDENTIALS_RELATIVE_URI environment variable when running under Amazon ECS
# as a task, making it fail to find the AWS security credentials. This will export the ENV variables that Boto expects
# to find and is a suitable workaround.
CREDS=`curl 169.254.170.2$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI`
export AWS_ACCESS_KEY_ID=`echo -n $CREDS | python2 -m json.tool | grep AccessKeyId | awk '{print $2}' | sed 's/[",]//g'`
export AWS_SECRET_ACCESS_KEY=`echo -n $CREDS | python2 -m json.tool | grep SecretAccessKey | awk '{print $2}' | sed 's/[",]//g'`
export AWS_SECURITY_TOKEN=`echo -n $CREDS | python2 -m json.tool | grep Token | awk '{print $2}' | sed 's/[",]//g'`

Keybase proof

I hereby claim:

  • I am aspotton on github.
  • I am aspotton (https://keybase.io/aspotton) on keybase.
  • I have a public key ASDrwiut23zglLbUsvMTmmcXGBzU4MiaN29fwGJI80yjOQo

To claim this, I am signing this object:

@aspotton
aspotton / screenshot.py
Last active January 11, 2023 15:27 — forked from initbrain/screenshot.py
Python screenshot tool (fullscreen/area selection)
#!/usr/bin/env python
# Python screenshot tool (fullscreen/area selection)
import sys
import os
from io import BytesIO
from PyQt5 import QtCore, QtGui
from PyQt5.QtGui import QPixmap, QScreen
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QSizePolicy, QGroupBox, QSpinBox, QCheckBox, QGridLayout, QPushButton, QHBoxLayout, QVBoxLayout, QFileDialog
from subprocess import getoutput
@aspotton
aspotton / run.sh
Created January 5, 2019 20:35
Use Nvidia GPU inside of an unprivileged container without nvidia-docker
# Assumes that these are installed on the host system:
# * nvidia binary drivers
# * CUDA
# * cuDNN
docker run -it --rm $(ls /dev/nvidia* | xargs -I{} echo '--device={}') $(ls /usr/lib/*-linux-gnu/{libcuda,libnvidia}* | xargs -I{} echo '-v {}:{}:ro') -v $(pwd):/code test:test /bin/bash
#!/usr/bin/perl
#
# syslog captures great imformation but the timestamps are very cryptic
# This script is handy because it prints syslog messages with translated, human readable timestamps
# Script originally from: https://linuxaria.com/article/how-to-make-dmesg-timestamp-human-readable
#
use strict;
use warnings;
@aspotton
aspotton / website_category_lookup.php
Last active September 16, 2015 03:34
Web Shrinker Website Category API: Public Preview - PHP Example
<?php
if (!isset($argv[1])) {
print "You need to give the URL to lookup the category for: {$argv[0]} http://www.example.com\n";
exit(1);
}
$uri = trim($argv[1]);
$request = "https://categories.webshrinker.com/preview/lookup/".strtr(base64_encode($uri), '+/', '-_');