Scott Watermasysk Husband, Father, Bootstrapper, Developer, Builder, Shipper.
Shorts are small posts and links. These are auto posted to @scottw on Twitter.

Revisiting delayed_job

After browsing the e-petition and dev.to source the one ruby gem that stood out to me is DJ. I am a huge fan of Sidekiq and use it everywhere. However, for small side projects, I might need to revisit DJ.

# - Apr 01, 2019

TabNine

Speaking of intellisense/autocompletion in Vim…I am still very happy with TabNine. All I can say is “It Just Works”.

👉 https://tabnine.com/

# - Apr 01, 2019

coc.nvim

Intellisense engine for vim8 & neovim, full language server protocol support as VSCode.

There are a couple of extra steps to get Ruby setup but seems to work really well. Surprisingly no JavaScript support as far as I can tell.

👉 https://github.com/neoclide/coc.nvim

# - Apr 01, 2019

Vs Code Tab By Number

One of the things that trips me up with VS Code is my muscle memory for switching tabs with ⌘ + number. I used this often with Atom and I am pretty sure I picked it from Sublime and/or Textmate.

Digging through the existing bindings, you can do this today with ⌃ + number. What makes this worse for me, ⌘ + 1, ⌘ + 2, etc do something today, but I am honestly not sure what it is. :)

There is an Atom commands plugin, but I do not need (or want) everything that comes with it. Instead, I went ahead and edited the following keybindings (under workbench.action.openEditorAtIndex).

Tabs by Number Bindings

# - Mar 28, 2019

The Market

From today’s Daily Stoic:

“The market might be rational…but the people who comprise it are not.”

# - Mar 27, 2019

Sorting Your Gems

I was looking through the Dev.to source, and the first thing that jumped out at me was the Gemfile was sorted (within each group). This made it much easier to scan and think about their dependencies.

Using Vim, I was able to sort my Gemfile in a couple of seconds.

  1. Select the lines within the group (or all of those outside of a group).
  2. enter command mode (:) and type sort

That’s it. Now, if you were like me, you still sometimes flipflop between ‘ and “ (working on it!), you will need to pick one (“) and do a find and replace %s/'/"/g as well otherwise things will not sort quite right.

# - Mar 25, 2019

Better than MVP

“Your smallest viable audience holds you to account. It forces a focus and gives you nowhere to hide.”

This is a much better way to think about your next product. What is the smallest audience you can target and still be successful?

👉 https://seths.blog/2019/03/almost-no-one-3/

# - Mar 25, 2019

Do Not Overthink Ruby

I was reading through the Ruby regex docs trying to figure out how to iterate over a string and replace all the matches of a particular pattern.

The tricky part is the matches are not one to one (not just a find and replace). I tried a bunch of different things and then started wishing gsub took a block….turns out it already does this.

Example:

"1234".gsub(/\d/) {|i| i.to_i * 2} # 2468

Even better, it handles all substitution

"Square this number: 5".gsub(/\d/) {|i| i.to_i * i_to_i}
# Square this number: 25
# - Mar 21, 2019

mini_sql

One of the best ways to improve page speed and reduce memory is to skip your ORM, especially when you are doing multiple small repetitive looks ups (ie, does a record existing in N tables).

This gem makes this approach very easy.

👉 https://github.com/discourse/mini_sql

# - Mar 19, 2019

TIL: Curly Bracket Substitution

You can use curly brackets for quick substitution in a shell command.

Curly Backet Example

Instead of manually typing the path out twice (or even tab completing it), you can list the parts to be swapped within curly brackets ({}).

# - Mar 12, 2019

CtrlP Shortcuts for Rails

I liked how @garybernhardt had specific rails shortcuts in vim for his Selecta script. As a fan of CtrlP + Ag, I did not want to switch, so I came up with the following which works well.

map <leader>gv :CtrlP app/views<cr>
map <leader>ga :CtrlP app/assets<cr>
map <leader>gc :CtrlP app/controllers<cr>
map <leader>gw :CtrlP app/workers<cr>
map <leader>gm :CtrlP app/models<cr>
map <leader>gl :CtrlP lib<cr>
map <leader>gs :CtrlP spec<cr>

The pattern should be obvious. One mistake I initially made was using:

map <leader>gl :CtrlP<cr>lib/

This ends up just entering lib/ for you in the search and does not explicitly limit the search to the lib directory. This is noticeably slower since each keystroke is a wasted search. Also, with a small directory name like lib, it is easy to have invalid fuzzy matches. The CtrlP + directory and then enter keeps the search focused on the specified directory only.

# - Mar 11, 2019

Gruvbox Contrast and ColorScheme Order

In cleaning up my .vimrc, I thought I completely screwed something up. Turns out it was:

If you are setting the value of g:gruvbox_contrast_dark or g:gruvbox_contrast_light and do not see any change try setting the contrast before colorscheme gruvbox in your configuration.

# - Mar 09, 2019
← Older Shorts Newer Shorts →