mirror of
https://github.com/jbranchaud/til
synced 2026-01-21 07:58:02 +00:00
Compare commits
4 Commits
2a68baf469
...
2808b39828
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2808b39828 | ||
|
|
84e2c9c6f4 | ||
|
|
39614e975e | ||
|
|
15337dfd71 |
@@ -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).
|
||||||
|
|
||||||
_1431 TILs and counting..._
|
_1433 TILs and counting..._
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -830,6 +830,7 @@ _1431 TILs and counting..._
|
|||||||
- [Execute A Raw SQL Query](prisma/execute-a-raw-sql-query.md)
|
- [Execute A Raw SQL Query](prisma/execute-a-raw-sql-query.md)
|
||||||
- [Grab A Limited Set Of Records](prisma/grab-a-limited-set-of-records.md)
|
- [Grab A Limited Set Of Records](prisma/grab-a-limited-set-of-records.md)
|
||||||
- [Open Connections To Multiple Databases](prisma/open-connections-to-multiple-databases.md)
|
- [Open Connections To Multiple Databases](prisma/open-connections-to-multiple-databases.md)
|
||||||
|
- [Override Table Name For Prisma Model](prisma/override-table-name-for-prisma-model.md)
|
||||||
- [Specify Alternate Location For Prisma Schema](prisma/specify-alternate-location-for-prisma-schema.md)
|
- [Specify Alternate Location For Prisma Schema](prisma/specify-alternate-location-for-prisma-schema.md)
|
||||||
|
|
||||||
### Python
|
### Python
|
||||||
@@ -1377,6 +1378,7 @@ _1431 TILs and counting..._
|
|||||||
- [Find Files With fd](unix/find-files-with-fd.md)
|
- [Find Files With fd](unix/find-files-with-fd.md)
|
||||||
- [Find Newer Files](unix/find-newer-files.md)
|
- [Find Newer Files](unix/find-newer-files.md)
|
||||||
- [Find Occurrences Of Multiple Values With Ripgrep](unix/find-occurrences-of-multiple-values-with-ripgrep.md)
|
- [Find Occurrences Of Multiple Values With Ripgrep](unix/find-occurrences-of-multiple-values-with-ripgrep.md)
|
||||||
|
- [Find Top-Level Directories Matching A Pattern](unix/find-top-level-directories-matching-a-pattern.md)
|
||||||
- [Fix Unlinked Node Binaries With asdf](unix/fix-unlinked-node-binaries-with-asdf.md)
|
- [Fix Unlinked Node Binaries With asdf](unix/fix-unlinked-node-binaries-with-asdf.md)
|
||||||
- [Forward Multiple Ports Over SSH](unix/forward-multiple-ports-over-ssh.md)
|
- [Forward Multiple Ports Over SSH](unix/forward-multiple-ports-over-ssh.md)
|
||||||
- [Generate A SAML Key And Certificate Pair](unix/generate-a-saml-key-and-certificate-pair.md)
|
- [Generate A SAML Key And Certificate Pair](unix/generate-a-saml-key-and-certificate-pair.md)
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ version from my `.tool-versions` file with a step that uses `set-output`.
|
|||||||
- name: Read Node.js version to install from `.tool-versions`
|
- name: Read Node.js version to install from `.tool-versions`
|
||||||
id: nodejs
|
id: nodejs
|
||||||
run: >-
|
run: >-
|
||||||
echo "::set-output name=NODE_VERSION::$(
|
echo "NODE_VERSION=$(
|
||||||
cat .tool-versions |
|
cat .tool-versions |
|
||||||
grep nodejs |
|
grep nodejs |
|
||||||
sed 's/nodejs \(.*\)$/\1/'
|
sed 's/nodejs \(.*\)$/\1/'
|
||||||
)"
|
)" >> $GITHUB_OUTPUT
|
||||||
```
|
```
|
||||||
|
|
||||||
`echo` runs the command in the string which sets `NODE_VERSION` as an output
|
`echo` runs the command in the string which sets `NODE_VERSION` as an output
|
||||||
@@ -45,4 +45,4 @@ This output value can be referenced in a later step.
|
|||||||
`steps` has a reference to the `nodejs` step (note the `id` above) which then
|
`steps` has a reference to the `nodejs` step (note the `id` above) which then
|
||||||
has `outputs` like the `NODE_VERSION`.
|
has `outputs` like the `NODE_VERSION`.
|
||||||
|
|
||||||
[source](https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#using-workflow-commands-to-access-toolkit-functions)
|
[source](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter)
|
||||||
|
|||||||
42
prisma/override-table-name-for-prisma-model.md
Normal file
42
prisma/override-table-name-for-prisma-model.md
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
# Override Table Name For Prisma Model
|
||||||
|
|
||||||
|
When defining your Prisma schema, you'll add models to your
|
||||||
|
`prisma/schema.prisma` file that look something like this:
|
||||||
|
|
||||||
|
```
|
||||||
|
model Book {
|
||||||
|
id BigInt @id @default(autoincrement()) @db.BigInt
|
||||||
|
title String
|
||||||
|
author String
|
||||||
|
publication_year Int
|
||||||
|
created_at DateTime @default(now())
|
||||||
|
updated_at DateTime @updatedAt
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The prisma client (ORM-layer) that gets generated will have a `Book` type and
|
||||||
|
you'll be able to reference the model to, for instance, create a record with
|
||||||
|
`prisma.book.create(...)`. Both of these things are derived from the model
|
||||||
|
name: `Book`.
|
||||||
|
|
||||||
|
The other thing that is derived from the model name is the name given to the
|
||||||
|
underlying database table. So you end up with a table called `Book`. You may,
|
||||||
|
however, prefer a table naming convention where this one would be named `books`
|
||||||
|
(snake_case and pluralized).
|
||||||
|
|
||||||
|
To achieve that, you have to manually override the table name with [the `@@map`
|
||||||
|
directive](https://www.prisma.io/docs/orm/reference/prisma-schema-reference#map-1).
|
||||||
|
Add it toward the bottom of the model like so:
|
||||||
|
|
||||||
|
```
|
||||||
|
model Book {
|
||||||
|
id BigInt @id @default(autoincrement()) @db.BigInt
|
||||||
|
title String
|
||||||
|
author String
|
||||||
|
publication_year Int
|
||||||
|
created_at DateTime @default(now())
|
||||||
|
updated_at DateTime @updatedAt
|
||||||
|
|
||||||
|
@@map("books")
|
||||||
|
}
|
||||||
|
```
|
||||||
36
unix/find-top-level-directories-matching-a-pattern.md
Normal file
36
unix/find-top-level-directories-matching-a-pattern.md
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# Find Top-Level Directories Matching A Pattern
|
||||||
|
|
||||||
|
I like using [`fd`](https://github.com/sharkdp/fd) as an alternative to `find`.
|
||||||
|
In my experience it is more intuitive to use. For instance, I wanted to find
|
||||||
|
all the top-level directories in my current directory that contained the word
|
||||||
|
`next`. I was able to get the command mostly right by guessing the flags, only
|
||||||
|
checking the man page once.
|
||||||
|
|
||||||
|
On my first attempt, it prompted me with a suggestion for a flag that wasn't
|
||||||
|
quite right. I tried `--depth`, but it should have been `--maxdepth`.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ fd --depth 0 next ./
|
||||||
|
error: Found argument '--depth' which wasn't expected, or isn't valid in this context
|
||||||
|
Did you mean --maxdepth?
|
||||||
|
```
|
||||||
|
|
||||||
|
Then I checked the man page for how to specify the file type as _directory_ --
|
||||||
|
using `-t` or `--type` with `d`.
|
||||||
|
|
||||||
|
And here is the command that gets me all top-level directories matching `next`
|
||||||
|
in my current directory:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ fd --maxdepth 1 --type d next ./
|
||||||
|
|
||||||
|
bookshelf-nextjs-prisma-postgres
|
||||||
|
bookshelf-prisma-nextjs-planetscale
|
||||||
|
my-next-app
|
||||||
|
next-bookshelf
|
||||||
|
next-personal-site
|
||||||
|
next-sanity-v3-example
|
||||||
|
try-trpc-next
|
||||||
|
```
|
||||||
|
|
||||||
|
See `man fd` for more details.
|
||||||
Reference in New Issue
Block a user