Skip to content

Instantly share code, notes, and snippets.

@victorlin
victorlin / zha-moes-zigbee-rotary-smart-knob-remote-control.yaml
Created December 20, 2023 06:35 — forked from blizzrdof77/zha-moes-zigbee-rotary-smart-knob-remote-control.yaml
ZHA - Moes Tuya Smart Knob (TS004F) controller for remote control devices
blueprint:
name: ZHA - Moes Tuya Smart Knob (TS004F) controller for remote control devices
description: Control remotes (e.g. volume up/down) with a Moes Tuya smart knob (the spinny ones). You can set functions for single press, rotating left, and rotating right.
domain: automation
source_url: https://gist.github.com/blizzrdof77/c30c388ca5f4ce7ed72752296767417d
input:
remote:
name: Smart Knob Device
description: Moes Tuya Smart Knob Device to use
selector:
@victorlin
victorlin / 1.t
Created October 31, 2022 21:55
testing Cram's temp directories
Create a new file in the test's temp directory.
$ cat newfile.txt
cat: .*: No such file or directory (re)
[1]
$ echo "hello" > newfile.txt
Create a new file in the test runner's temp directory (shared).
$ cat "$TMP"/newfile.txt
@victorlin
victorlin / github-delete-stale-branches.js
Last active March 20, 2024 02:27
Delete stale branches from the GitHub repo's stale branches page (github.com/user/repo/branches/stale). Originally from https://stackoverflow.com/a/69089905
// Paste in browser console and run
async function deleteStaleBranches(delay=500) {
var stale_branches = document.getElementsByClassName('js-branch-delete-button');
for (var i = 0; i < stale_branches.length; i++)
{
stale_branches.item(i).click();
await new Promise(r => setTimeout(r, delay));
}
}

Reset Final Cut Pro Trial

This still works on FCP 10.6.9.

  1. Open Terminal app.

  2. Paste the following line:

    mv -v ~/Library/Application\ Support/.ffuserdata ~/.Trash
@victorlin
victorlin / concat-wyze-video-files.sh
Last active September 10, 2023 20:13
Wyze cameras store video files in a folder hierarchy. This script creates a time lapse video file per hour.
#!/bin/bash
#
# Wyze cameras store video files in a folder hierarchy. This script creates a time lapse video file per hour.
date_folder="$1"
for hour_folder in $(ls "$date_folder")
do
echo "$date_folder-$hour_folder"
for hour_video in $(ls "$date_folder/$hour_folder" | grep -v "\-800k\.mp4")
for ext in 360 MP4 JPG THM LRV
do
mkdir $ext
mv *.$ext $ext
done
@victorlin
victorlin / populate-github-project-beta.py
Last active March 24, 2022 09:28
Helper functions to add all issues of a repository to a GitHub project (beta), with example usage at bottom of script. For https://github.com/github/feedback/discussions/6765
import requests
import json
GH_GRAPHQL_URL = 'https://api.github.com/graphql'
TOKEN = '' # add your PAT with read:org and write:org scope
def get_json_result(query):
headers={'Authorization': f'token {TOKEN}'}
r = requests.post(GH_GRAPHQL_URL, json={'query': query}, headers=headers)
@victorlin
victorlin / deploy-functions.sh
Created August 15, 2021 16:30
helper scripts for serratus-summary-uploader
pushd manager
zip -rq package .
aws lambda update-function-code \
--function-name srarun-upload-manager \
--zip-file fileb://./package.zip
rm package.zip
popd
pushd worker
zip -rq package .
@victorlin
victorlin / create_dated_folders.sh
Last active October 19, 2022 23:35
shell scripts to organize and modify scanned images from Epson FastFoto FF-680W
for f in *.jpg; do
date="${f:0:10}"
if ! [ -d "${date}" ]; then
echo "creating folder ${date}"
mkdir "${date}"
fi
echo "moving ${f}"
mv ${f} ${date}
done
{
"properties": {
"sra": "ERR2756788",
"genome": "cov3ma",
"date": "200607-01:47"
},
"families": [
{
"family": "AMR",
"score": "100",