Skip to content

Instantly share code, notes, and snippets.

View joshukraine's full-sized avatar
🏠
Working from home

Joshua Steele joshukraine

🏠
Working from home
View GitHub Profile
@joshukraine
joshukraine / vim-performance.md
Created May 20, 2023 10:13
What I’ve learned about slow performance in Vim

What I’ve learned about slow performance in Vim

January 27, 2018

I started this PR because Vim had gotten very slow and laggy. The problem seemed particularly painful when editing Ruby files. For example, when trying to move down by holding the “j” key, the downward motion would continue for a second or two after I’d released the key, causing me to far overshoot my target.

There were many other performance issues beyond scrolling. Sometimes even just simply typing in insert mode was noticeably slow. I knew things were getting serious when I found myself watching tutorial videos for Microsoft Visual Studio Code.

Happily, I’ve found a path back to a speedy and responsive Vim. Here’s what I’ve learned.

@joshukraine
joshukraine / obsidian-web-clipper.js
Last active February 3, 2023 09:08 — forked from kepano/obsidian-web-clipper.js
Obsidian Web Clipper Bookmarklet to save articles and pages from the web (for Safari, Chrome, Firefox, and mobile browsers)
javascript: Promise.all([import('https://unpkg.com/turndown@6.0.0?module'), import('https://unpkg.com/@tehshrike/readability@0.2.0'), ]).then(async ([{
default: Turndown
}, {
default: Readability
}]) => {
/* Optional vault name */
const vault = "obsidian-main";
/* Optional folder name such as "Clippings/" */
@joshukraine
joshukraine / zsh-error.txt
Last active May 3, 2020 05:47
Permissions error from zsh
[oh-my-zsh] Insecure completion-dependent directories detected:
drwxrwxr-x 7 joshukraine admin 224 May 2 07:35 /usr/local/share/zsh
drwxrwxr-x 12 joshukraine admin 384 May 2 07:33 /usr/local/share/zsh/site-functions
[oh-my-zsh] For safety, we will not load completions from these directories until
[oh-my-zsh] you fix their permissions and ownership and restart zsh.
[oh-my-zsh] See the above list for directories with group or other writability.
[oh-my-zsh] To fix your permissions you can do so by disabling
[oh-my-zsh] the write permission of "group" and "others" and making sure that the
@joshukraine
joshukraine / syntime_re1.txt
Created January 27, 2018 07:47
Vim syntime report in a ruby file with regexpengine=1
TOTAL COUNT MATCH SLOWEST AVERAGE NAME PATTERN
0.057130 9929 4703 0.000084 0.000006 rubySymbol [[:space:],{(]\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[!?]\=:[[:space:],]\@=
0.052588 7070 1844 0.000155 0.000007 rubySymbol []})\"':]\@1<!\<\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[!?]\=:[[:space:],]\@=
0.050374 5257 31 0.000122 0.000010 rubyKeywordAsMethod \(defined?\|exit!\)\@!\<[_[:lower:]][_[:alnum:]]*[?!]
0.042170 5228 0 0.000079 0.000008 rubyString \%(^.*\%(\%(class\|::\)\s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]`\z([^`]*\)`.*\)\@<=\n
0.040648 5228 0 0.000088 0.000008 rubyString \%(^.*\%(\%(class\|::\)\s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]\z(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\>.*$\)\@<=\n
0.039729 5228 0 0.000071 0.000008 rubyString \%(^.*\%(\%(class\|::\)\s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]'\z([^']*\)'.*\)\@<=\n
0.039659 5228 0 0.000072
@joshukraine
joshukraine / syntime_re0.txt
Created January 27, 2018 07:44
Vim syntime report in a ruby file with regexpengine=0
TOTAL COUNT MATCH SLOWEST AVERAGE NAME PATTERN
0.494780 7555 0 0.000914 0.000065 rubyString \%(^.*\%(\%(class\|::\)\s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]`\z([^`]*\)`.*\)\@<=\n
0.489842 7555 0 0.000980 0.000065 rubyString \%(^.*\%(\%(class\|::\)\s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]\z(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\>.*$\)\@<=\n
0.481765 7555 0 0.000933 0.000064 rubyString \%(^.*\%(\%(class\|::\)\s*\|\%([]}).]\)\s\|\w\)\@<!<<\z(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\).*$\)\@<=\n
0.478531 7555 0 0.000908 0.000063 rubyString \%(^.*\%(\%(class\|::\)\s*\|\%([]}).]\)\s\|\w\)\@<!<<[-~]'\z([^']*\)'.*\)\@<=\n
0.476628 7555 0 0.000893 0.000063 rubyString \%(^.*\%(\%(class\|::\)\s*\|\%([]}).]\)\s\|\w\)\@<!<<"\z([^"]*\)".*\)\@<=\n
0.475943 7555 0 0.000882 0.000063 rubyString \%(^.*\%(\%(class\|::\)\s*\|\%([]}).]\)\s\|\w\)\@<!<<`\z([^`]*\)`

That time I had to compile Vim from source...

January 2, 2018

Recently, something broke in Homebrew's version of Vim. Several things seemed weird, but what first caught my eye was that misspelled words were no longer highlighted in Markdown files. This is a feature that I have previously configured and I use it often when writing blog posts and such.

Initially, I assumed I had a problem with my Vim settings. After much troubleshooting and no joy, I finally uninstalled Homebrew's version of Vim which caused my system to fall back to the default version of Vim that ships with macOS. Suddenly the highlighting worked fine.

After doing some further research, I decided I would try to compile and install Vim myself. After some googling and patching together a few different articles, this is what worked for me.

rails: bin/rails server
postgres: postgres -D /usr/local/var/postgres
redis: redis-server /usr/local/etc/redis.conf
livereload: bin/guard -P livereload

This is a test!

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

# lib/capistrano/tasks/remote_rake_task.rake
#
# This task allows you to run rake tasks on the remote server using Capistrano.
# The rake task itself is passed in as an argument.
# Example:
# bin/cap staging "task:invoke[app:setup]"
#
# References:
# http://www.jetthoughts.com/blog/magic/2013/09/26/capistrano-3-passing-parameters-to-your-task.html
# http://stackoverflow.com/questions/23828950/how-to-run-custom-rake-task-via-capistrano-3
@joshukraine
joshukraine / default.json
Last active August 29, 2015 14:03
My powerline vim theme
// ~/.config/powerline/themes/vim/default.json
{
"segment_data": {
"branch": {
"before": ""
},
"modified_indicator": {
"args": { "text": "+" }
},