Skip to content

Instantly share code, notes, and snippets.

@scottopell
scottopell / gist:5038ed75213755fcc49fe949366c6c23
Created August 12, 2016 14:50
Bind local port to remote port with plain SSH (basically ngrok)
# generic version
ssh -R <remote_port>:<local_interface>:<local_port> <remote machine>
# example (dev is a host configured in ~/.ssh/config)
ssh -R 4567:localhost:4567 dev
# Ubuntu hosts require an extra step of config
# http://askubuntu.com/questions/50064/reverse-port-tunnelling/50075#50075
# (run on server)
sudo echo -e "Match User scott\n GatewayPorts yes" >> /etc/ssh/sshd_config
@scottopell
scottopell / xz_to_google_cloud.md
Created August 19, 2017 15:51
Compress files with xz and upload archive to google cloud

I always forget these steps and have to google for them, even though they're super simple

Prereq:

  • pip install gsutil
  • gsutil config, have your project id ready.
  1. tar --create --verbose --xz --file images.tar.xz /directory/containing/images/*
  2. gsutil cp images.tar.xz gs://<bucket name>
@scottopell
scottopell / freeview_filter.markdown
Created September 2, 2017 15:29
DirectTV Now FreeVIEW filter out subscriber only shows

DirectTV Now added a FreeVIEW thing where you can watch some tv shows for free, but they don't show you only the shows that are available on "FreeVIEW", because that would be too convenient.

Luckily, they helpfully mark these subscriber only shows with a badge on the /watch/shows endpoint.

Here's a bookmarklet to hide the subscriber only shows.

javascript:document.querySelectorAll("[data-label='SUBSCRIBE']").forEach( (el) => { el.parentNode.parentNode.parentNode.parentNode.style.display = 'none'; });
@scottopell
scottopell / mp3_archiving.md
Last active December 10, 2017 18:20
Audio archive/management/conversion for audiobooks/podcasts

Scenario

You have a large audio file that has been split into multiple mp3s.

Goal

You want to merge these and convert to a m4a (optional) so that you can use it with https://github.com/scottopell/audiobook-podcast

Steps:

# Combine MP3s
ffmpeg -i "concat:$(ls *.mp3 | tr '\n' '|')" -acodec copy out.mp3
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite;
var createHash = require('crypto').createHash;
suite.add('md2', () => {
createHash('md2').update('HELLO WORLD').digest('hex');
})
.add('md4', () => {
@scottopell
scottopell / launch.json
Created March 31, 2018 15:27
How to debug jest tests with create-react-app-ts scripts
// This took me way too long to figure out.
// Needs node 8.4.0 or greater to work (I think, based on https://github.com/nodejs/node/issues/7593#issuecomment-322966866)
// The magic sauce here is that react-scripts-ts/scripts/test.js creates an inline jest config
// that it passes through. This does things like map css files properly, so if you try to use
// jest directly then it won't work.
{
"version": "0.2.0",
"configurations": [
{
@scottopell
scottopell / get_all_bitbucket.sh
Created August 25, 2016 21:54
Clone all user's repos on bitbucket
#!/bin/bash
# Script to clone all repositories under a user from bitbucket
# Usage: getAllRepos.sh [username]
repos=$(curl -u ${1} https://api.bitbucket.org/1.0/users/${1} | jq -r '.repositories[] | .slug')
vcs=git # or hg
for repo_name in $repos
do
echo -e "\tFetching $repo_name"
$vcs clone "ssh://$vcs@bitbucket.org/${1}/$repo_name"
@scottopell
scottopell / setup_hc2.markdown
Last active February 24, 2020 08:03
Setup torrent + media server on Orange Pi HC2

Orange pi HC2 setup

This is my 3rd iteration of this guide, and now it appears that armbian officially supports the orange pi pc2!

Goals

  • rtorrent
  • plex
  • flood (or similar rtorrent web interface)
  • support external usb3 hd with exfat
@scottopell
scottopell / serversetup.md
Last active April 18, 2020 16:28
Just random shit that I always have to look up when I'm setting up a server
@scottopell
scottopell / simpleget.go
Last active September 1, 2022 15:50
Where does Go get its trusted CAs from?
package main
import (
"crypto/tls"
"fmt"
)
// go build && strace -o strace-out.txt -f -e trace=file ./simpleget
func main() {
conn, err := tls.Dial("tcp", "www.google.com:443", nil)