1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-21 07:58:02 +00:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Dylan Irlbeck
28db5fc192 Merge 5365e75267 into 4f2399de13 2024-11-22 16:35:10 -05:00
jbranchaud
4f2399de13 Add Useful ActiveSupport Constants For Durations as a Rails TIL 2024-11-22 09:45:20 -06:00
jbranchaud
7573119c59 Add Allow Key-Repeating With Cursor as a Workflow TIL 2024-11-21 11:11:17 -06:00
Dylan Irlbeck
5365e75267 Update git show TIL 2020-04-29 22:17:44 -05:00
4 changed files with 84 additions and 4 deletions

View File

@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186). For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
_1512 TILs and counting..._ _1514 TILs and counting..._
--- ---
@@ -1040,6 +1040,7 @@ _1512 TILs and counting..._
- [Update Column Versus Update Attribute](rails/update-column-versus-update-attribute.md) - [Update Column Versus Update Attribute](rails/update-column-versus-update-attribute.md)
- [Upgrading Your Manifest For Sprocket's 4](rails/upgrading-your-manifest-for-sprockets-4.md) - [Upgrading Your Manifest For Sprocket's 4](rails/upgrading-your-manifest-for-sprockets-4.md)
- [Use IRB And Ruby Flags With Rails Console](rails/use-irb-and-ruby-flags-with-rails-console.md) - [Use IRB And Ruby Flags With Rails Console](rails/use-irb-and-ruby-flags-with-rails-console.md)
- [Useful ActiveSupport Constants For Durations](rails/useful-active-support-constants-for-durations.md)
- [Validate Column Data With Check Constraints](rails/validate-column-data-with-check-constraints.md) - [Validate Column Data With Check Constraints](rails/validate-column-data-with-check-constraints.md)
- [Verify And Read A Signed Cookie Value](rails/verify-and-read-a-signed-cookie-value.md) - [Verify And Read A Signed Cookie Value](rails/verify-and-read-a-signed-cookie-value.md)
- [Where Am I In The Partial Iteration?](rails/where-am-i-in-the-partial-iteration.md) - [Where Am I In The Partial Iteration?](rails/where-am-i-in-the-partial-iteration.md)
@@ -1744,6 +1745,7 @@ _1512 TILs and counting..._
- [Add Subscriber To Kit Form Via API](workflow/add-subscriber-to-kit-form-via-api.md) - [Add Subscriber To Kit Form Via API](workflow/add-subscriber-to-kit-form-via-api.md)
- [Add Subtitles To Existing Mux Video Asset](workflow/add-subtitles-to-existing-mux-video-asset.md) - [Add Subtitles To Existing Mux Video Asset](workflow/add-subtitles-to-existing-mux-video-asset.md)
- [Access 1Password Credential From CLI](workflow/access-1password-credential-from-cli.md) - [Access 1Password Credential From CLI](workflow/access-1password-credential-from-cli.md)
- [Allow Key-Repeating With Cursor](workflow/allow-key-repeating-with-cursor.md)
- [Change Window Name In iTerm](workflow/change-window-name-in-iterm.md) - [Change Window Name In iTerm](workflow/change-window-name-in-iterm.md)
- [Configure Email Redirect With Cloudflare](workflow/configure-email-redirect-with-cloudflare.md) - [Configure Email Redirect With Cloudflare](workflow/configure-email-redirect-with-cloudflare.md)
- [Convert An ePub Document To PDF On Mac](workflow/convert-an-epub-document-to-pdf-on-mac.md) - [Convert An ePub Document To PDF On Mac](workflow/convert-an-epub-document-to-pdf-on-mac.md)

View File

@@ -2,16 +2,16 @@
Sometimes you want to view a file on another branch (without switching Sometimes you want to view a file on another branch (without switching
branches). That is, you want to view the version of that file as it exists branches). That is, you want to view the version of that file as it exists
on that branch. `git show` can help. If your branch is named `my_feature` and on that branch. `git show` can help. If the other branch is named `some_branch` and
the file you want to see is `app/models/users.rb`, then your command should the file you want to see is `app/models/users.rb`, then your command should
look like this: look like this:
``` ```
$ git show my_feature:app/models/users.rb $ git show some_branch:app/models/users.rb
``` ```
You can even tab-complete the filename as you type it out. You can even tab-complete the filename as you type it out.
See `man git-show` for more details. See `man git-show` for more details.
[source](http://stackoverflow.com/questions/7856416/view-a-file-in-a-different-git-branch-without-changing-branches) [source](https://stackoverflow.com/questions/7856416/view-a-file-in-a-different-git-branch-without-changing-branches)

View File

@@ -0,0 +1,45 @@
# Useful ActiveSupport Constants For Durations
Whenever I'm passing a duration to a function, I like to [name it with the
unit](https://ruudvanasseldonk.com/2022/03/20/please-put-units-in-names)
relative to the value it represents. For instance, if I need to pass in an hour
duration in seconds, I might write the following line:
```ruby
hour_in_seconds = 60 * 60
# or
hour_in_seconds = 3600
```
ActiveSupport has a [Duration
class](https://api.rubyonrails.org/classes/ActiveSupport/Duration.html) with a
series of constants that we can reach for.
```ruby
> ActiveSupport::Duration::SECONDS_PER_MINUTE
=> 60
> ActiveSupport::Duration::SECONDS_PER_HOUR
=> 3600
> ActiveSupport::Duration::SECONDS_PER_DAY
=> 86400
> ActiveSupport::Duration::SECONDS_PER_WEEK
=> 604800
> ActiveSupport::Duration::SECONDS_PER_MONTH
=> 2629746
> ActiveSupport::Duration::SECONDS_PER_YEAR
=> 31556952
```
Though it is fun to know about these, we should keep in mind that this class
provides support for what is likely to be a more useful abstraction layer:
```ruby
> 1.hour
=> 1 hour
> 3.hours
=> 3 hours
> 1.day.to_i
=> 86400
```

View File

@@ -0,0 +1,33 @@
# Allow Key-Repeating With Cursor
I recently installed the Vim extension for Cursor. This is the same extension
for VSCode since Cursor is built on VSCode. A lot of the expected Vim behavior
was working. However there was one glaring point of friction.
I often hold down keys like `k` and `j` to go up and down several lines when
I'm absent-mindedly scrolling around. This wasn't working with the Vim mode
extension. I'd hold `j` down and the cursor would move down a single line and then
stop.
The first thing the Vim extension tells you to do is run a command to enable
key-repeating. These instructions are specific to VSCode:
```bash
$ defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool false
```
That won't work for cursor which is a separate application with a distinct
`CFBundleIdentifier`. You can check the current identifier in Cursor's
`Info.plist` file to be sure, but it should be `com.todesktop.230313mzl4w4u92`.
Run this to target Cursor:
```bash
$ defaults write com.todesktop.230313mzl4w4u92 ApplePressAndHoldEnabled -bool false
```
Then restart Cursor.
Now key-repeating in Vim mode should be working.
[source](https://github.com/getcursor/cursor/issues/777#issuecomment-1690996370)