Skip to content

Instantly share code, notes, and snippets.

@jamesmacfie
jamesmacfie / README.md
Created October 22, 2019 02:53
iTerm 2 - script to change theme depending on Mac OS dark mode

How to use

In iTerm2, in the menu bar go to Scripts > Manage > New Python Script

Select Basic. Select Long-Running Daemon

Give the script a decent name (I chose auto_dark_mode.py)

Save and open the script in your editor of choice.

#!/bin/sh
echo "# 24-bit (true-color)"
# based on: https://gist.github.com/XVilka/8346728
term_cols="$(tput cols || echo 80)"
cols=$(echo "2^((l($term_cols)/l(2))-1)" | bc -l 2> /dev/null)
rows=$(( cols / 2 ))
awk -v cols="$cols" -v rows="$rows" 'BEGIN{
s=" ";
m=cols+rows;
@cfraizer
cfraizer / pretty.jq
Created August 20, 2019 18:20
first attempt at JSON prettifier in jq
# 9 = \t
# 10 = \n
# 13 = \r
# 32 = (space)
# 34 = "
# 44 = ,
# 58 = :
# 91 = [
# 92 = \
# 93 = ]
@martinheld
martinheld / GraphQL introspection query via curl.md
Last active July 19, 2024 07:13
GraphQL introspection query via curl

GraphQL introspection query via curl

cat introspection_query.json

{ 
  "query": "query IntrospectionQuery {
      __schema {
        queryType { name }
        mutationType { name }
@7sDream
7sDream / ffmpeg_bilibili.sh
Last active August 27, 2023 18:46
Convert video to meet bilibili's requirement. Video: 1080p60, H264, avg bitrate 6k, max bitrate 24k, max key frame interval 10s; Audio: aac, 44100Hz, 192k. With optional GPU acceleration support.
#!/bin/bash
# ===== setting =====
FORMAT=mp4
VIDEO_CODEC=libx264
VIDEO_GPU_CODEC=h264_videotoolbox
PROFILE=high
LEVEL=4.2
PRESET=veryslow
@v-fox
v-fox / motioninterpolation.vpy
Last active September 19, 2023 00:48 — forked from phiresky/motioninterpolation.vpy
On-CPU motion interpolation for ≤480@144, ~720@120, ≥1080p@60 playback in mpv
#!/usr/bin/python
# vim: set ft=python:
# see the README at https://gist.github.com/v-fox/43c287426c366679afc4c65eece60cbc
# source: https://github.com/mpv-player/mpv/issues/2149
# source: https://github.com/mpv-player/mpv/issues/566
# source: https://github.com/haasn/gentoo-conf/blob/nanodesu/home/nand/.mpv/filters/mvtools.vpy
import vapoursynth as vs
import functools
@akorn
akorn / runcached
Last active September 3, 2024 22:15
Run specified (presumably expensive) command with specified arguments and cache result. If cache is fresh enough, don't run command again but return cached output.
#!/bin/zsh
#
# Purpose: run specified command with specified arguments and cache result. If cache is fresh enough, don't run command again but return cached output.
# Also cache exit status and stderr.
# Copyright (c) 2019-2023 András Korn; License: GPLv3
# Use silly long variable names to avoid clashing with whatever the invoked program might use
RUNCACHED_MAX_AGE=${RUNCACHED_MAX_AGE:-300}
RUNCACHED_IGNORE_ENV=${RUNCACHED_IGNORE_ENV:-0}
RUNCACHED_IGNORE_PWD=${RUNCACHED_IGNORE_PWD:-0}
@EricFromCanada
EricFromCanada / tigerbrew-node-config.command
Last active October 24, 2021 23:17
Configure an OS X system as a Tigerbrew test node.
#!/bin/bash
# ====================================================================
# tigerbrew-node-config.command
#
# Configure an OS X system as a Tigerbrew test node.
# Assumes that Developer Tools & Remote Desktop Client are installed.
# Only tested on 10.4 and 10.5 so far.
#
# @EricFromCanada
@mzpqnxow
mzpqnxow / disable-mdns-chrome.sh
Last active June 22, 2023 07:58
Disable MDNS in Chrome via Chrome policies on the commandline
#!/bin/bash
#
# This assumes you are using "Chrome" from the official Google site via the .deb or .rpm
# This may or may not work with your distributions "Chromium" or "Chrome" package!
#
# Run this script then restart Chrome, you will see it is no longer bound to UDP:5353
#
mkdir -p /etc/opt/chrome/policies/{managed,recommended} || echo FAIL, ARE YOU ROOT
chmod go-w /etc/opt/chrome/policies/managed || echo FAIL, ARE YOU ROOT
cat > /etc/opt/chrome/policies/managed/managed_policy.json << 'EOF'
@RichardBronosky
RichardBronosky / similarities.sh
Created February 8, 2019 07:47
Identify how similar a file is to each file in a group of others.
#!/bin/bash
fileA="$1"
shift
for fileB in "$@"; do
(
# diff once grep twice with the help of tee and stderr
diff $fileA $fileB | \
tee >(grep -cE '^< ' >&2) | \
grep -cE '^> ' >&2