1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-18 14:38:01 +00:00

Compare commits

..

5 Commits

Author SHA1 Message Date
nick-w-nick
31b9ef8335 Merge 295fe153ad into 3abfa92b64 2024-12-02 12:24:36 -05:00
jbranchaud
3abfa92b64 Add Write System Clipboard To A File as a Mac TIL 2024-12-01 09:58:15 -06:00
jbranchaud
d086d3b943 Add Find System-wide Config File For User as a jj TIL 2024-11-30 14:38:52 -06:00
jbranchaud
f64257f02c Add Organize Pages In Route Groups as a Next.js TIL 2024-11-29 12:21:50 -06:00
jbranchaud
b329d36888 Add Block Syntaxes Have Different Precedence as a Ruby TIL 2024-11-28 14:06:07 -06:00
5 changed files with 119 additions and 1 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).
_1519 TILs and counting..._
_1523 TILs and counting..._
---
@@ -573,6 +573,7 @@ _1519 TILs and counting..._
### jj
- [Colocate jj And git Directories For Project](jj/colocate-jj-and-git-directories-for-project.md)
- [Find System-wide Config File For User](jj/find-system-wide-config-file-for-user.md)
### jq
@@ -636,6 +637,7 @@ _1519 TILs and counting..._
- [Specify App When Opening From Command Line](mac/specify-app-when-opening-from-command-line.md)
- [Use Default Screenshot Shortcuts With CleanShot X](mac/use-default-screenshot-shortcuts-with-cleanshot-x.md)
- [View All Windows Of The Current App](mac/view-all-windows-of-the-current-app.md)
- [Write System Clipboard To A File](mac/write-system-clipboard-to-a-file.md)
### MongoDB
@@ -686,6 +688,7 @@ _1519 TILs and counting..._
- [Fetch Does Not Work In API Serverless Function](nextjs/fetch-does-not-work-in-api-serverless-function.md)
- [Make Environment Variable Publicly Available](nextjs/make-environment-variable-publicly-available.md)
- [Match Middleware On Groups Of Paths](nextjs/match-middleware-on-groups-of-paths.md)
- [Organize Pages In Route Groups](nextjs/organize-pages-in-route-groups.md)
- [Precedence Of Dot Env Files](nextjs/precedence-of-dot-env-files.md)
- [Push A Route With A URL Object](nextjs/push-a-route-with-a-url-object.md)
- [Redirect An Unauthorized User](nextjs/redirect-an-unauthorized-user.md)
@@ -1188,6 +1191,7 @@ _1519 TILs and counting..._
- [Audit Your Ruby Project For Any CVEs](ruby/audit-your-ruby-project-for-any-cves.md)
- [Assoc For Hashes](ruby/assoc-for-hashes.md)
- [Block Comments](ruby/block-comments.md)
- [Block Syntaxes Have Different Precedence](ruby/block-syntaxes-have-different-precedence.md)
- [Build HTTP And HTTPS URLs](ruby/build-http-and-https-urls.md)
- [Chaining Multiple RSpec Change Matchers](ruby/chaining-multiple-rspec-change-matchers.md)
- [Check For Any Overlaps In List Of Ranges](ruby/check-for-any-overlaps-in-list-of-ranges.md)

View File

@@ -0,0 +1,25 @@
# Find System-wide Config File For User
The `jj` CLI can be configured in a couple different places. When I recently
ran a `jj config` command, I was curious where specifically it was getting set.
Those changes didn't appear in the repo's config (`./.jj/repo/config.toml`).
That makes sense since it would only apply to that repo. So, where is the
system-wide config file?
The following commond shows where on your machine it is located.
```bash
$ jj config path --user
/Users/jbranchaud/Library/Application Support/jj/config.toml
```
Now, the next time I set a config like this:
```bash
$ jj config set --user ui.paginate never
```
or want to check what other config options are set to, I can visit that path
and take a look.
[source](https://github.com/martinvonz/jj/blob/main/docs/config.md)

View File

@@ -0,0 +1,19 @@
# Write System Clipboard To A File
MacOS has two CLI utilities `pbcopy` and `pbpaste` which, respectively, copy
_to_ and paste _from_ the system clipboard via the CLI.
Let's say I've just copied a large block of text from somewhere onto my system
clipboard. I now want to paste that into a new file. Instead of creating a new
file, opening it up in my preferred editor, pasting all that text, and saving
the file, I can run one small command from the CLI.
```bash
$ pbpaste > data.txt
```
This redirects the contents of `pbpaste` (which is the system clipboard) into
the file `data.txt`. If that file doesn't already exist, then it will be
created before the data is written to it.
See `man pbpaste` for more details.

View File

@@ -0,0 +1,41 @@
# Organize Pages In Route Groups
With the Next.js App Router we can organize pages without affecting the URL
path structure by nesting those directories and pages within a _Route Group_. A
Route Group is directory where the name is surrounded by parentheses, e.g.
`/(symbols)`.
For instance, in my [Ruby Operator
Lookup](https://www.visualmode.dev/ruby-operators) project, I have the
following structure:
```bash
$ exa --true src/app/ruby-operators
src/app/ruby-operators
├── (symbols)
│ ├── ampersand
│ │ └── page.mdx
│ ├── arbitrary-keyword-arguments
│ │ └── page.mdx
│ ├── asterisk
│ │ └── page.mdx
│ ├── at-symbol
│ │ └── page.mdx
│ ├── backtick
│ │ └── page.mdx
│ ├── ...
│ └── underscore
│ └── page.mdx
├── client-layout.tsx
├── layout.tsx
├── page.tsx
└── wrapper.ts
```
I'm able to organize all the different symbols and operators under a separate
directory `/(symbol)/`. That makes development easier. However, the end result
routing still has each symbol located directly under `/ruby-operators/`, e.g.
`/ruby-operators/ampersand`.
[source](https://nextjs.org/docs/app/getting-started/project-structure#route-groups)

View File

@@ -0,0 +1,29 @@
# Block Syntaxes Have Different Precedence
There are two syntaxes for defining a block in Ruby. The semantically shorthand
syntax uses the curly braces (`{}`). The semantically multi-line syntax uses
`do` and `end`. For nearly all intents and purposes they are interchangable.
It is, however, worth noting that the `do`/`end` version has a lower precedence
than the already low precedence of `{}`. That said, you have to write some
weird code for this to become an issue.
Let's say we have two methods, `method_one` and `method_two`. They are both
called on the same line like below and then followed by a block argument. Which
method receives the block argument?
```ruby
method_one method_two { |n|
puts "Executing a block: #{n}"
}
method_one method_two do |n|
puts "Executing a block: #{n}"
end
```
In the first case, with the curly braces, `method_two` receives the block as an
argument. In the second case, with the `do`/`end`, `method_one` receives the
block as an argument.
[source](http://localhost:3131/ruby-operators/curly-braces#block-shorthand)