If <></>
triggers a syntax error in Visual Studio Code, try the following:
- Switch file's language mode to TypeScript React
- Switch file's language mode back to JavaScript React
The error should be gone.
{ | |
"name": "react-example-app", | |
"version": "1.0.0", | |
"description": "Demonstrates usage of React, React Router and Express.", | |
"main": "server.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
"start": "node server.js", | |
"ensure-dirs": "mkdirp frontend\\dist && mkdirp frontend\\dist\\scripts && mkdirp frontend\\dist\\styles && mkdirp frontend\\dist\\assets", | |
"prewatch": "npm run ensure-dirs && npm run copy-assets && npm run copy-index", |
import { Knex } from 'knex' | |
export async function up(knex: Knex): Promise<any> { | |
await knex.schema.createTable('test_setup', (table: Knex.TableBuilder) => { | |
table.integer('foobar'); | |
}); | |
} | |
export async function down(knex: Knex): Promise<any> { | |
await knex.schema.dropTable('test_setup'); |
If <></>
triggers a syntax error in Visual Studio Code, try the following:
The error should be gone.
Commands:
pbcopy
- Copy to clipboardpbpaste
- Paste from clipboardExample: Pipe filenames to clipboard
$ ls -1 | pbcopy
These commands are useful if copied text should be 100% the same as the output. Selecting and copying text in terminal always has more whitespace than needed or one or two characters are missing. So this is a perfect solution to avoid those.
Check constraints are useful for validating INSERT and UPDATE queries. With Knex.js, you have to use raw
calls to add or drop constraints.
Add a constraint to check that my_column
in my_table
is at least 0:
knex.schema.raw(`
ALTER TABLE
my_table
ADD CONSTRAINT
Sometimes you need to search within backups but don't want to restore the dump to a real database.
Backup files produced by Heroku Postgres are compressed. So they need to be converted to plain text.
input.dump
input.dump
to plain text using pg_restore
:
3rd party cookies have been disabled in most browsers and it affects apps that use the Auth0 Lock.
Without proper configuration (which is pretty hard to find from Auth0's documentation) the app won't let users log in. This took me a hours of work to figure out how the changes should be implemented.
To fix the problem you need the following:
Question: How to test what kind of error an async function throws and how to apply matchers to the rejected value?
Answer: You need to await
the expect
call and then inspect the rejects
property of the returned Jest object.
async function doSomethingAsync(value?: string) {
if (!value) throw new MyFancyError('Some error text');
return value;
https://kvs-vishnu23.medium.com/is-aws-cdk-better-than-terraform-85194e7a42cd
https://jsherz.com/aws/cdk/terraform/2023/04/29/terraform-vs-cdk.html