Skip to content

Instantly share code, notes, and snippets.

@Nathaniel-Wu
Nathaniel-Wu / tm-restore.sh
Created December 25, 2022 20:09
Current macOS Time Machine implementation on APFS volumes makes it very complicated to restore files from command line, this script shows how to do so.
#!/usr/bin/env bash
# MIT License
#
# Copyright (c) 2022 Nathaniel-Wu
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
// ==UserScript==
// @name ResetEra Auto Dark Mode
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Automatically toggle built-in dark mode on resetera.com
// @author Nathaniel Wu
// @match *.resetera.com/*
// @license Apache-2.0
// @supportURL https://gist.github.com/Nathaniel-Wu/13f3c865e190c2b182e41b9978c49782
// @grant none
@Nathaniel-Wu
Nathaniel-Wu / youtube-check-out-updated-channels.js
Last active July 16, 2021 04:19
Open channels with updates in new tabs, to be launched from Tampermonkey context menu
// ==UserScript==
// @name YouTube Check Out Updated Channels
// @namespace http://tampermonkey.net/
// @version 0.5
// @description Open channels with updates in new tabs
// @author Nathaniel Wu
// @include *www.youtube.com/*
// @license Apache-2.0
// @supportURL https://gist.github.com/Nathaniel-Wu/fabd62df2d6146121fa4b9cfcae08763
// @run-at context-menu
// ==UserScript==
// @name Reddit Auto Dark Mode
// @namespace http://tampermonkey.net/
// @version 0.13
// @description Automatically toggle built-in dark mode on reddit.com
// @author Nathaniel Wu
// @match *://*.reddit.com/*
// @license Apache-2.0
// @supportURL https://gist.github.com/Nathaniel-Wu/f638b2fee2ece92742bfbf7d4db19f18
// @grant none
// ==UserScript==
// @name YouTube Jump to Channel Videos
// @namespace http://tampermonkey.net/
// @version 0.6
// @description Redirect links in the subscription list to videos tab instead of the home tab (only works for open in new tab/window)
// @author Nathaniel Wu
// @include *www.youtube.com/*
// @license Apache-2.0
// @supportURL https://gist.github.com/Nathaniel-Wu/b9cbdc29b2b33c7d49993ef70d7993d7
// @grant none
// ==UserScript==
// @name Zhihu Auto Dark Mode
// @namespace http://tampermonkey.net/
// @version 0.4
// @description Automatically toggle hidden built-in dark mode on zhihu.com
// @author Nathaniel Wu
// @include *.zhihu.com/*
// @exclude *link.zhihu.com/*
// @exclude *www.zhihu.com/question/*/log
// @exclude *www.zhihu.com/people/*/logs
@Nathaniel-Wu
Nathaniel-Wu / waifu2x-build.sh
Last active August 17, 2022 21:15
Build waifu2x on macOS
#!/usr/bin/env bash
# before running the script, make sure OpenCV has been installed through Homebrew
git clone https://github.com/DeadSix27/waifu2x-converter-cpp.git && cd waifu2x-converter-cpp
# caveat: libw2xc.dylib will be referenced by the executable using the build path, so you may want to copy the repo somewhere you eventually want the binaries to be
# latest working release is 5.3.4 (27ad20e6a2007d0415a7a1d7fc957e81395ab06b)
git checkout 27ad20e6a2007d0415a7a1d7fc957e81395ab06b
# create some temporary symbolic links, otherwise cmake and make will not find the files
ln -sf "${HOMEBREW_PREFIX}/opt/opencv/include/opencv4/opencv2" "${HOMEBREW_PREFIX}/opt/opencv/include/opencv2"
# run the next four lines only if you haven't installed LLVM through Homebrew
mkdir -p "${HOMEBREW_PREFIX}/opt/llvm/bin"