Skip to content

Instantly share code, notes, and snippets.

Avatar

Linfeng Li llinfeng

  • The University of Michigan
  • Ann Arbor, MI, USA
View GitHub Profile
@llinfeng
llinfeng / Overleaf_V2_mappings.js
Last active Apr 26, 2020
Greasemonkey Script with Forward search in Overleaf
View Overleaf_V2_mappings.js
// ==UserScript==
// @name Overleaf Editor Custom VIM Keybindings
// @namespace http://tampermonkey.net/
// @version 0.1
// @match https://www.overleaf.com/project/*
// @grant none
// Source 1: https://groups.google.com/d/msg/ace-discuss/gwXMzUM17I4/9B_acHBSCQAJ
// Source 2: https://www.overleaf.com/learn/how-to/How_can_I_define_custom_Vim_macros_in_a_vimrc_file_on_Overleaf%3F
// ==/UserScript==
@llinfeng
llinfeng / xchange_viewer_underline_change.ahk
Last active Mar 2, 2020
Use right-click and then `f` to change underline style for XChange Viewer
View xchange_viewer_underline_change.ahk
#IfWinActive ahk_exe PDFXCview.exe
; Note, this script is built on one major assumption:
; 1. that there is a labeled routine called CenterMouseOnActiveWindow, from: https://www.autohotkey.com/boards/viewtopic.php?t=60433
; 2. that the Property window shall open at the **center** of the active window. For XChangeViewer, this is exactly the case.
~RButton::
Hotkey, f, f, On
KeyWait, f, D T3
Hotkey, f, f, Off
if(!ErrorLevel) {
; Send, {Esc}
@llinfeng
llinfeng / TP_middle_Scroll.ahk
Last active May 20, 2021
AHK - scroll with middle-mouse-key + trackpoint for Thinkpad keyboards
View TP_middle_Scroll.ahk
; Midbutton down for scrolling {{{
; Feature: with acceleration as intended.
; Source: http://forum.notebookreview.com/threads/ultranav-middle-click-button-scroll.423415/
; Linking source: https://superuser.com/questions/91074/thinkpad-trackpoint-scrolling-and-middle-click-possible
; Working version {{{
$*MButton::
Hotkey, $*MButton Up, MButtonup, off
KeyWait, MButton, T0.2
If ErrorLevel = 1
{
@llinfeng
llinfeng / cVimrc
Created Jan 6, 2020
cVim white list
View cVimrc
let blacklists = ["https://mail.google.com/*","http://localhost/*","https://calendar.google.com/*","https://www.overleaf.com/*","https://app.getpocket.com/*","https://gallery.mailchimp.com/*","https://colab.research.google.com/*","https://www.tumblr.com/*","https://www.youtube.com/*","https://docs.google.com/*","https://todoist.com/*","https://toggl.com/*","https://groups.google.com/*"]
" Settings
@llinfeng
llinfeng / AHK_Markdown_to_go.ahk
Created Dec 7, 2019
An Autohotkey snippet that converts raw Markdown texts into "pastable" rich-text, for Gmail and even MS Word.
View AHK_Markdown_to_go.ahk
::togo::
; Debugging tips
; 1. Check if pandoc is installed. If not, the best way is to install through choco.
; choco install page:https://chocolatey.org/packages/pandoc
; 2. Check if `paste.exe` is available to PowerShell, same thing for `clip.exe` ==> these two are necessary Windows utilities/executable that were called with Ctrl+V and Ctrl+C
Run, PowerShell "paste.exe | pandoc -f markdown-smart --from=gfm -t HTML | Set-Clipboard -AsHtml ; echo 'Conversion done.' "
; Caveat: single quotes are pasted wrongly, as question marks.
Return
@llinfeng
llinfeng / win_and_wsl_registry.vim
Created Jan 28, 2019
For Xming-illustrated-Gvim-from-WSL on Windows 10, pressing `<c-c>` writes to registry `+` and `<c-v>` shall past from registry `+`. This is different from Win-Gvim's behavior, where `*`-registry is used.
View win_and_wsl_registry.vim
" Snippet from my ~/.vimrc, where I use `Y` for fetching the absolute path, and use `<leader><leader>n` to fetch the name of the file.
" Other mappings were done a while ago. Kept for potential audience as they do demonstrate a wide variety of flags applicable for the expand() function.
if has('win32')
"Copy the full file path to windows clipboard.
nnoremap Y :let @* = expand("%:p")<CR>
"Copy the file name to windows clipboard.
nnoremap yyy :let @* = expand("%:p:t")<CR>
"Now using leaders:
" Full path
nnoremap <leader><leader>f :let @* = expand("%:p")<CR>
@llinfeng
llinfeng / cVimrc
Created Nov 20, 2018
cVim on Chrome
View cVimrc
let blacklists = ["https://calendar.google.com/*","https://mail.google.com/*","http://www.yilan.io/*"]
@llinfeng
llinfeng / restore_c_w_for_Firefox.ahk
Created Nov 6, 2018
Restore <c-w> to delete a word in Firefox, with solutation to Tridactyl
View restore_c_w_for_Firefox.ahk
; Since Github refuse to render anything in the old Firefox 55, I need to switch to Tridactyl with the newer Firefox.
; Yet, the <c-w> is missing from Tridactyl, and it is impossible to implemnet an Insert mode there
; This maps <c-w> to delete the word, and <alt + q> to take out (close) a tab.
; Lastly, <Alt + Shift + Q> will close the entire window. It is impractical to kill all existing process as done on Mac.
#IfWinActive ahk_exe firefox.exe
;questionable piece, 2018-11-06: may not get used to it in the end.
!q:: send ^w
^w:: Send ^+{Left}{BS}
; End of questionable piece.
!+q:: send !{F4}
@llinfeng
llinfeng / spell_check_Vim.ahk
Created Nov 4, 2018
Use AutoHotKey + Google for spell-checking: in Gvim.exe (Vim on Windows)
View spell_check_Vim.ahk
; How it works? Well, when you type a single word with erranous spellings to Google, it way "Did you mean ...".
; This AHK script grab that piece of Google Suggestion and pass it back to the clipboard.
; Purpose: select the world to the left of the cursor, and correct using Google:
; Credits: AutoHotkey Community (Linfeng is not able to find the original source.)
; Please comment if you are able to find the source of those fantastic regex expressions
;; Usage: use Ctrl + Alt + Shift + H, to select the word to the left of your
;; active cursor, and replace it with whatever Google corrects it to be.
;; Warning: only work best for very-close, but wrong, spellings.
@llinfeng
llinfeng / spell_check.ahk
Created Nov 4, 2018
Use AutoHotKey + Google for spell-checking: in Normal text editors
View spell_check.ahk
; How it works? Well, when you type a single word with erranous spellings to Google, it way "Did you mean ...".
; This AHK script grab that piece of Google Suggestion and pass it back to the clipboard.
; Purpose: select the world to the left of the cursor, and correct using Google:
; Credits: AutoHotkey Community (Linfeng is not able to find the original source.)
; Please comment if you are able to find the source of those fantastic regex expressions
;; Usage: use Ctrl + Alt + Shift + H, to select the word to the left of your active cursor,
;; and replace it with whatever Google corrects it to be.
;; Warning: only work best for very-close, but wrong, spellings.