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 / 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 / sh.sh
Created September 8, 2016 15:40
Embed SRT file into mp4 with ffmpeg
# got this from http://stackoverflow.com/questions/8672809/use-ffmpeg-to-add-text-subtitles
ffmpeg -i infile.mp4 -f srt -i infile.srt -c:v copy -c:a copy -c:s mov_text outfile.mp4
# confirmed working with the following ffmpeg
# (installed using `brew 'ffmpeg', args: ['with-libvorbis', 'with-libvpx']` )
ffmpeg version 3.1.2 Copyright (c) 2000-2016 the FFmpeg developers
built with Apple LLVM version 7.3.0 (clang-703.0.31)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.1.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-libvorbis --enable-libvpx --disable-lzma --enable-vda
@scottopell
scottopell / remove_audio_track.md
Last active September 19, 2023 19:29
How to remove an audio track from an mkv
  1. Install mkvtoolsnix.
  2. brew install --with-qt5 mkvtoolnix
  3. Use mkvinfo to get the audio track IDs that you want.
  4. mkvinfo *.mkv
  5. Note that the audio track IDs are not the track numbers. Check the man page of mkvmerge or mkvinfo for more details.
  6. Use mkvmerge to create a copy of the mkv with ONLY the desired tracks using --audio-tracks.
  7. mkvmerge -o out.mkv -a 2 orig.mkv
@scottopell
scottopell / fix_exfat_drive.md
Last active June 5, 2024 07:56
Fix corrupted exFAT disk macOS/OSX

exFAT support on macOS seems to have some bugs because my external drives with exFAT formatting will randomly get corrupted.

Disk Utility is unable to repair this at first, but the fix is this:

  1. Use diskutil list to find the right drive id.
  2. You want the id under the IDENTIFIER column, it should look like disk1s1
  3. Run sudo fsck_exfat -d <id from above>. eg sudo fsck_exfat -d disk1s3
  4. -d is debug so you'll see all your files output as they're processed.
  5. Answer YES if it gives you the prompt Main boot region needs to be updated. Yes/No?
@scottopell
scottopell / port_forward_dg2470A.md
Last active January 18, 2024 20:19
How to forward a port on Arris DG2470A

Port forwarding should be fairly straightforward, but what Arris doesn't tell you is that you need to have the firewall on in order for port forwarding settings to have an effect.

I don't know why the "firewall off" option would mean "block everything", but as best I can tell, that was the case on my Arris DG2470A (from RCN, could be some custom firmware that RCN uses?)

So step by step:

@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 / zpty.md
Last active November 27, 2023 12:50
zpty

zpty

Zsh has a feature called zpty which creates a pseudo-terminal in the background.

According to the docs, this can be useful to run a program in the background that expects to be run in a normal terminal environment.

Some zsh themes such as pure use this to run commands asynchronously. Pure uses the zsh plugin zsh-async for this.

@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 / 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