ss.py: a cli wrapper for the Semantic Scholar API.

[About] [GitHub]

Putting word count in Vim statusline for LaTeX files

This ftplugin updates the word count in the statusline on every save. More frequent updates slow Vim down and cause random rendering problems.

" .vim/after/ftplugin/tex.vim

function CountWords()
  silent return systemlist('texcount ' .. expand('%:p'))[2]
endfunction

let b:wordcount = CountWords()

augroup tex
  autocmd! * <buffer>
  autocmd BufWritePost <buffer> :let b:wordcount = CountWords()
augroup END

setlocal statusline=%{b:wordcount}

Update

Using vim’s job_start function, I can asynchronously update the word count, preventing the short hang on save.

" .vim/after/ftplugin/tex.vim

function UpdateWordcount(_, msg)
  if match(a:msg, 'Words in text:') >= 0
    let b:wordcount = a:msg
    let &l:statusline = &l:statusline " Refresh statusline
  endif
endfunction

augroup my_tex
  autocmd! * 
  autocmd BufEnter,BufWritePost  call job_start(
        \  [ 'texcount', expand('%:p') ], 
        \  {'out_cb': 'UpdateWordcount'}
        \) 
augroup END

let b:wordcount = 'Words in text: ...'
setlocal statusline=%{b:wordcount}

Configuring Zathura

I finally got Zathura (the pdf viewer) configured the way I want it on MacOS. I installed using homebrew following these instructions. I set up an automator script to launch Zathura for me according to this gist. I chose my colors based on the blacks and whites in the pencil colorscheme.

Here’s my zathurarc file:

set selection-clipboard clipboard
set guioptions ""
set window-title-basename true

set recolor true
set recolor-keephue true
set recolor-lightcolor \#F1F1F1
set recolor-darkcolor \#181818
set default-bg \#E5E6E6
set completion-bg \#181818
set completion-fg \#F1F1F1
set completion-group-bg \#181818
set completion-group-fg \#F1F1F1
set completion-highlight-fg \#181818
set inputbar-bg \#181818
set inputbar-fg \#F1F1F1
set statusbar-bg \#181818
set statusbar-fg \#F1F1F1

Good luck! 📄


Washington State

I learned some Blender and used some open source elevation data to make a nice looking relief map of Washington State. Check out how I made it here. 📍

Rendered relief map of WA

Camping in Cottonwood Wash

This last weekend, Caitlyn and I backpacked up Cottonwood Wash in Utah’s San Rafael Swell, a beautiful canyon all to ourselves. We even spotted some petroglyphs. ⛰️

1983 USGS map of Mexican Mountain

Course notes from CS183

These are my notes from the course CS183: Foundations of Machine Learning. They are imperfect and incomplete but I really enjoyed making them. If you would like to make edits email me and I can send you the source code. 📓