TIL is my collection of short, technical daily learnings. 196 and counting.
Upgrade Rubygems
To update rubygems: gem install rubygems-update update_rubygems gem update --system
TIL is my collection of short, technical daily learnings. 196 and counting.
To update rubygems: gem install rubygems-update update_rubygems gem update --system
If you’ve been mucking around in your Ruby dependencies, bundle pristine is your friend; it resets all of the gems in your Gemfile to their pristine condition. This can be a slow on a big project. Target the specific gems you worked on today with: $ bundle pristine <gemname>
“Select isn’t broken.” If you’re working on a CSS file, and none of your changes are being applied, check for typos, crashed servers, misplaced files, etc. Once you’ve ruled out simple mistakes, you might have a syntax error like this: .klass { opacity: 0.5; }; The trailing semicolon is incorrect, and none of the CSS below it can be understood by the browser. Change this to: .klass { opacity: 0.5; } There may be some environments where a broken CSS file fails loudly; Code Sandbox or Codepens are not among them. If you’re changing CSS and nothing is happening, start looking for syntax errors. ...
I have an .rgignore file that ignores half of a monorepo that I almost never want to search in. Sometimes though, I do need to search that repo, and I’d rather not edit my ignore file. Here’s how I override it for one search: rg "I mean," --no-ignore This will search in every directory, even those I’m ignoring via the .rgignore.
Adding | pbcopy to the end of any command will send the standard output to your clipboard. ls -al | pbcopy inside a rails project directory allowed me to paste this: Gemfile Gemfile.lock README.md Rakefile app bin config config.ru db features lib log public script spec test tmp vendor
When you command-click on a Chrome bookmarks folder, it opens every link in the folder in a new tab. I did this by accident; so what’s the use case? I use bookmark folders to categorize my ‘work links’: hosting, error monitoring, Git hosting, online docs, etc. With this TIL, I could use this folder to open a new Chrome session and instantly load it with all the pages I need to be effective.
Today while writing a Vim regex to change every instance of it (ignoring larger matches like itemized), we stumbled upon Vim regex word boundary matching. Given this file: foo foobar The following Vim regex will match on both the first and second line: :%s/foo/baz/g But with word boundaries, we’ll only match (and change) the first line, because only the first foo is a standalone word: :%s/\<foo\>/baz/g
Tagging releases with Git is a good idea. In case your tags get off track, here is how you delete a Git tag locally and on a remote: $ git tag -d abc $ git push origin :refs/tags/abc To git@github.com:hashrocket/hr-til - [deleted] abc It gets trickier if you’re using Semantic Versioning, which includes dots in the tag name. The above won’t work for v16.0.0. This will: $ git tag -d v16.0.0 $ git push origin :v16.0.0 To git@github.com:hashrocket/hr-til - [deleted] v16.0.0
In my never-ending quest to better summarize my work at the end of the day using computers, I discovered today the Git --author flag. It works like this: $ glg --since=midnight --author=dev+jwworth+mikechau@hashrocket.com * 4ba91a8 (HEAD, origin/checkout, checkout) Add guard for manual entry of employee discount * 3a4e4c9 Seed a coupon and code and auto-apply in preview * cb1adee Add discount ... The alias glg is discussed here. I use this when multiple developers or teams are committing throughout the day to the same repository, to disambiguate our work from others. Ready to paste into your billing software of choice.
Today I learned a great way to count the links in a README or link collection. Vim Regex! :%s/- \[//n In Vimspeak: On every line, find all of the times where - [ (the beginning of a Markdown bulleted hyperlink) occurs, count them, and report the number of matches. See :help substitute in Vim for more information. h/t Josh Branchaud
Don’t miss my next essay
Hear from me immediately when I post: no ads, unsubscribe anytime.