Skip to content

Instantly share code, notes, and snippets.

View vyspiansky's full-sized avatar

Ihor Vyspiansky vyspiansky

View GitHub Profile
@vyspiansky
vyspiansky / redis-command-line-interface.md
Created January 31, 2023 21:49
Redis command line interface

Go to Redis command line interface

redis-cli -h 127.0.0.1 -p 6379

Info and stats about the server

127.0.0.1:6379> INFO
@vyspiansky
vyspiansky / sequelize-log-generated-sql-query-statements.md
Created January 31, 2023 21:45
Sequelize: show generated SQL query statements

If you disabled query logging, you can still log individual queries when needed.

await User.findOne({
  logging: console.log, // log SQL statement to console
  // ...
});
@vyspiansky
vyspiansky / self-signed-certificate-in-debian-ubuntu.md
Created January 31, 2023 21:24
Self-signed certificate in Debian/Ubuntu

Debian/Ubuntu image already included a self-signed certificate.

docker run \
  --rm \
  -e POSTGRES_PASSWORD=password \
  postgres:12 \
  -c ssl=on \
  -c ssl_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem \
 -c ssl_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
@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;