Skip to content

Instantly share code, notes, and snippets.

View fanzeyi's full-sized avatar

Zeyi (Rice) Fan fanzeyi

View GitHub Profile
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
LWin & c::Send, ^c
LWin & v::Send, ^v
LWin & x::Send, ^x
LWin & a::Send, ^a
LWin & t::Send, ^t
@fanzeyi
fanzeyi / twitter-darkmode.user.js
Last active November 21, 2020 06:17
Twitter Auto Dark Mode
// ==UserScript==
// @name Twitter auto darkmode
// @version 1
// @grant none
// @match *://twitter.com/*
// ==/UserScript==
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', e => {
const isDarkMode = e.matches ? 1 : 0;
document.cookie = `night_mode=${isDarkMode};path=/;domain=.twitter.com;secure`;
@fanzeyi
fanzeyi / pull-webhook.py
Created May 26, 2019 10:15
GitHub stdlib Python webhook for auto pulling (Python 3)
# -*- coding: utf-8 -*-
import json
import hmac
import hashlib
import subprocess
from http.server import HTTPServer, BaseHTTPRequestHandler
def sign_request(body):
// ==UserScript==
// @name Reshare to Rebroadcast
// @namespace https://zr.is
// @version 0.1.1
// @description Make Douban great again!
// @author Zeyi Fan
// @match https://www.douban.com/*
// @grant none
// ==/UserScript==
(function() {
function escapeQuote(str) {
return str.replace("\"", "\\\"");
}
function buildAria2Url(name, url) {
return `aria2c -c -s10 -k1M -x16 --enable-rpc=false ` +
`-o "${escapeQuote(name)}" ` +
`--header "${escapeQuote(window.navigator.userAgent)}" ` +
`--header "Referer: ${escapeQuote(window.location.toString())}" ` +
class Hello {
constructor(foo, bar) {
this.foo = foo;
this.bar = bar;
}
otherfun() {
return 1;
}

Keybase proof

I hereby claim:

  • I am fanzeyi on github.
  • I am fanzeyi (https://keybase.io/fanzeyi) on keybase.
  • I have a public key whose fingerprint is 5B05 09B5 AF59 BBF1 2CAE B79B F9DB A8F1 81ED 79BF

To claim this, I am signing this object:

// ==UserScript==
// @name Revert Reshare
// @namespace http://zr.is/
// @version 0.3.1
// @description Make Reshare Great Again!
// @author Zeyi Fan
// @match https://www.douban.com/*
// @grant GM_addStyle
// ==/UserScript==
@fanzeyi
fanzeyi / init.lua
Last active January 28, 2019 15:09
Hammerspoon Configuration
local last_alert = nil
function displaySong(player)
artist, name = player.getCurrentArtist(), player.getCurrentTrack()
if (last_alert ~= nil) then
hs.alert.closeSpecific(last_alert)
end
last_alert = hs.alert.show(artist .. " - " .. name)
@fanzeyi
fanzeyi / iterm.diff
Created July 15, 2016 09:19 — forked from chemzqm/iterm.diff
iterm2
diff --git a/autoload/dispatch/iterm.vim b/autoload/dispatch/iterm.vim
index 7b52012..068f95f 100644
--- a/autoload/dispatch/iterm.vim
+++ b/autoload/dispatch/iterm.vim
@@ -21,22 +21,23 @@ function! dispatch#iterm#handle(request) abort
endfunction
function! dispatch#iterm#spawn(command, request, activate) abort
- let script = dispatch#isolate([], dispatch#set_title(a:request), a:command)
+ let script = s:isolate(a:request.command)