TIL is my collection of short, technical daily learnings. 188 and counting.
Jump to N Percent of a File
From normal mode, N% will jump you to that percentage of the file. So 50% jumps to halfway through the file.
TIL is my collection of short, technical daily learnings. 188 and counting.
From normal mode, N% will jump you to that percentage of the file. So 50% jumps to halfway through the file.
Unused dependencies are bad: they increase the size of your project, slow down processes, require maintenance, and send incorrect messages to fellow developers about what’s important. To get find unused dependencies in Ruby, I’ve been using gem stale: gem stale gem stale list gems along with most recent access times. If the last access time was the day you set up the app, that gem is a candidate for removal.
The longer I program (ahem), the bigger I want my terminal fonts. I think most programmers should be using a bigger font than they are. Complicating matters, the standard font for iTerm is miniscule on a computer monitor. Today I discovered iTerm’s ‘View > Size Changes Update Profile’ feature. When enabled, changes to your font size via ⌘ + and ⌘ - will be applied to your iTerm profile. The next time you open iTerm, the new font size will persist.
Hit K on a keyword, and Vim looks up the program under the keyword. It’s a bit jarring because Vim appears to shell out from your buffer to show the definition. To see that man page in Vim, load the man.vim plugin from command mode or in your .vimrc: :runtime! ftplugin/man.vim Now, you can read man pages as a Vim buffer: :Man curl
“Post-gres-Q-L”, “Post-grey-sequel”, “Postgres”… how do you say it? And where did the name come from? PostgreSQL was originally named POSTGRES– all caps. The name was chosen because it was the successor to the Ingres database developed at UC Berkeley. As the system adopted SQL standards and features, the name was changed to PostgreSQL. From the docs: Many people continue to refer to PostgreSQL as “Postgres” (now rarely in all capital letters) because of tradition or because it is easier to pronounce. This usage is widely accepted as a nickname or alias. ...
Linters are great, except when they aren’t. One example is Rubocop’s BlockLength lint. For example, I don’t care if my RSpec describe and context blocks are too long. Nontrivial test blocks will never be short enough to match a reasonable rule about blocks. I’ve disabled this lint for these blocks with Rubocop’s configuration file: # .rubocop.yml Metrics/BlockLength: IgnoredMethods: ['context', 'describe'] Opting out of just these blocks lets me enforce this rule everywhere else.
Today I learned about the method __id__, aliased object_id, in Ruby. It returns a unique integer identifier for any Ruby object. A few examples: > Object.new.object_id => 7024702983434 > name = "jake" => "jake" > name.object_id == name.object_id => true > "thawed".object_id == "thawed".object_id => false > "frozen".freeze.object_id == "frozen".freeze.object_id => true I’ve never used this method in practice, but I hope to someday.
I love autojump. I use it because I think that remembering my location in a directory structure relative to other directories, so I can navigate with cd, is mental energy I could be using for something else. Today I learned that autojump has a jo command, which jumps to a directory and opens it in your file explorer. jo Desktop This might be a throwaway lesson if I wasn’t regularly sidetracked by the MacOS file explorer. Finding a file using the file explorer is a routine operation I have yet to do fluidly on a Mac. This helps!
When I rebase, I force-push altered history using the flag --force-with-lease instead of the commonly-used --force. git push --force-with-lease But why? This is a TIL for me because I’ve used this command for years without reading the docs. Take it away, docs: This option allows you to say that you expect the history you are updating is what you rebased and want to replace. If the remote ref still points at the commit you specified, you can be sure that no other people did anything to the ref. ...
Here’s some code that made me do a double take. something = items[nil] It’s that [nil]. What’s going on here? It turns out that items is the return of a call to Ruby’s group_by. group_by groups by whatever the block evaluates to, including nil. [ { shipping: 'fedex', id: 1 }, { shipping: 'fedex', id: 2 }, { id: 3 } ].group_by { |item| item[:shipping] } => { 'fedex' => [{ shipping: 'fedex', id: 1 }, { shipping: 'fedex', id: 2 }], nil => [{ id: 3 }] } Hence the key nil. ...
Don’t miss my next essay
Hear from me immediately when I post: no ads, unsubscribe anytime.