Skip to content

Instantly share code, notes, and snippets.

View vyspiansky's full-sized avatar

Ihor Vyspiansky vyspiansky

View GitHub Profile
@vyspiansky
vyspiansky / knex-js-multiple-order-by-columns.md
Last active January 11, 2023 15:13
Knex.js multiple orderBy() columns
knex
  .select()
  .table('products')
  .orderBy('name', 'desc')
  .orderBy('id', 'asc')
@vyspiansky
vyspiansky / postgresql-connection-string.md
Created January 11, 2023 15:06
PostgreSQL connection string / URL format

PostgreSQL connection string / URL format

postgresql://[user[:password]@][netloc][:port][/dbname][?param1=value1&...]
@vyspiansky
vyspiansky / react-tips-and-tricks.md
Created January 11, 2023 08:46
React Tips and Tricks (draft)

React: assign a key to its children

React.Children.toArray(/*...*/)
@vyspiansky
vyspiansky / check-preflight-request.sh
Created November 14, 2022 09:27
Bash: check preflight request
curl -v -i -X OPTIONS -H "Origin: <WEBSIDE_URL>" \
-H 'Access-Control-Request-Method: POST' \
-H 'Access-Control-Request-Headers: Accept, Content-Type, Origin, Referer, User-Agent, X-YOUR-CUSTOM-HEADER' \
"<XHR_URL>"
@vyspiansky
vyspiansky / postgres-generate-test-data.sql
Last active September 28, 2022 10:15
PostgreSQL: Generate test data
do $$
begin
for i in 1000001..11000000 loop
INSERT INTO table_name(
field_id
field_2,
field_3
) values(
i,
'<field 2 value>',
@vyspiansky
vyspiansky / ssl-postgres-connect-using-sequelize.md
Last active January 31, 2023 21:19
How to connect to Postgres via SSL using Sequelize
const sequelize = new Sequelize(DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD, {
  host: DATABASE_HOST,
  dialect: 'postgres',
  port: DATABASE_PORT,
  ssl: {
    ca: fs.readFileSync(DATABASE_TLS_CERT).toString(),
    rejectUnauthorized: true,
    servername: DATABASE_HOST
 }
@vyspiansky
vyspiansky / dummy-text-file.txt
Last active August 23, 2022 08:22
Dummy text files (Lorem Ipsum)
What is Lorem Ipsum?
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
Where does it come from?
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discov
@vyspiansky
vyspiansky / create-protected-zip-archive-on-macos.md
Last active September 29, 2021 09:06
Creating password protected Zip archive using Terminal on macOS
zip -er <ZIP_ARCHIVE_NAME>.zip <PATH_TO_FOLDER>

Note! Drag & Drop a desired folder into the Terminal or enter the path of your folder manually.

@vyspiansky
vyspiansky / node-terminal-commands.md
Last active September 20, 2021 20:41
Terminal commands for Node.js Development (draft)

Terminal commands for Node.js Development

How to start any new Node.js project:

npx license mit > LICENSE
npx gitignore node
npx covgen <YOUR_EMAIL>
npm init -y
@vyspiansky
vyspiansky / symfony-console-commands.md
Last active September 20, 2021 20:25
Symfony Console Commands (draft)

Symfony 4/5 Console Commands (draft)

Run custom command

APP_DEBUG=false php bin/console app:your-command

Dump .env files in .env.local.php