Skip to content

Instantly share code, notes, and snippets.

@nickv2002
nickv2002 / fzf-aws.sh
Last active June 25, 2025 00:40
AWS CLI Quick Switch (using fzf)
#!/bin/sh
# sets the AWS_PROFILE env var with a fzf choice
# make sure to prefix the script with a dot so it runs in your native shell, eg `. ./fzf-aws.sh`
# Read the AWS config file
config_file="$HOME/.aws/config"
# Use awk to get a list of profiles (handles both [profile name] and [default])
profile_choices=$(awk '/^\[profile / {gsub(/^\[profile |\]$/, ""); print $0} /^\[default\]/ {print "default"}' "$config_file" | awk '{$1=$1;print}')
# Check if the first argument is non-empty and matches a profile (pure shell)
@nickv2002
nickv2002 / undupe-transode.py
Created January 19, 2020 05:20
Transcode Found Video Files to HEVC (H.265) and optimally remove the older versions
#!/usr/bin/env python3
import os
import sys
import glob
import subprocess
import shlex
import shutil
import pathlib
import itertools
#!/usr/bin/env python
# coding=utf-8
import json, os, sys, io, re
from pprint import pprint
with io.open('/Users/nick/Documents/dominiontabs/card_db/en_us/cards.json') as data_file:
cardDict = json.load(data_file)
with io.open('/Users/nick/Documents/dominiontabs/card_db/en_us/card_groups.json') as data_file:
groupDict = json.load(data_file)
@nickv2002
nickv2002 / YouTubePlayerViaTVJS.swift
Last active October 21, 2021 06:19
Swift code to play YouTube videos on AppleTV tvOS via a TVJS call using XCDYouTubeKit
//
// Created by Nick Vance on 12/4/15.
// Copyright © 2015 ToWatchList. All rights reserved.
//
import AVKit
import XCDYouTubeKit
import TVMLKit
class YTPlayerViewController: AVPlayerViewController, AVPlayerViewControllerDelegate {
@nickv2002
nickv2002 / mean_median_filters.py
Last active July 7, 2023 02:07 — forked from bhawkins/medfilt.py
1-Dimentional Mean and Median Filters
#!/usr/bin/env python
def medfilt (x, k):
"""Apply a length-k median filter to a 1D array x.
Boundaries are extended by repeating endpoints.
"""
import numpy as np
assert k % 2 == 1, "Median filter length must be odd."
assert x.ndim == 1, "Input must be one-dimensional."