Skip to content

Instantly share code, notes, and snippets.

View vyspiansky's full-sized avatar

Ihor Vyspiansky vyspiansky

View GitHub Profile
@vyspiansky
vyspiansky / postgres-commands.md
Created January 31, 2023 21:21
Postgres: useful commands

DB restart

postgres=# SELECT pg_reload_conf();
  pg_reload_conf
----------------
  t
(1 row)
@vyspiansky
vyspiansky / gzip-compress-decompress-in-nodejs.md
Last active February 8, 2023 12:20
Node.js gzip compress & decompress example
const zlib = require('zlib');

const buf = Buffer.from('hello world', 'utf-8');

zlib.gzip(buf, (err, compressed) => {
  if (err) {
    console.error(err);
  }
@vyspiansky
vyspiansky / docker-clear-all.md
Last active January 26, 2023 21:10
Docker Clear all
docker kill $(docker ps -q)
docker rm $(docker ps -a -q)
docker rmi $(docker images -q -a)
@vyspiansky
vyspiansky / javascript-tomorrow.md
Created January 26, 2023 21:05
Tomorrow in JavaScript
const today = new Date()
const tomorrow = new Date(today)
tomorrow.setDate(tomorrow.getDate() + 1)

// NOTE: If you also want to reset the time to "tomorrow at 00:00:00",
// you can do so by calling tomorrow.setHours(0,0,0,0).
@vyspiansky
vyspiansky / javascript-html-entities.md
Created January 26, 2023 21:02
HTML entities in JavaScript
// Simplified implementation
String(str).replace(/&/g, '&')
  .replace(/</g, '&lt;')
  .replace(/>/g, '&gt;')
  .replace(/"/g, '&quot;');
@vyspiansky
vyspiansky / macos-terminal-specific-php-version-first.md
Created January 26, 2023 20:54
Use a specific PHP version first in macOS Terminal
@vyspiansky
vyspiansky / winston-disable-logging.md
Created January 26, 2023 20:38
Disable Winston's logging

Disable Winston's logging when running unit tests

import { logger } from './logger'; 
logger.silent = true;
@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(/*...*/)