Skip to content

Instantly share code, notes, and snippets.

View vyspiansky's full-sized avatar

Ihor Vyspiansky vyspiansky

View GitHub Profile
@vyspiansky
vyspiansky / docker-compose.md
Created February 1, 2023 09:41
Docker compose

Docker compose

Up a certain container only

docker-compose up -d <NAME>
docker-compose logs

Note: Just drop the -d flag if you want to see the logs echoed to stdout.

@vyspiansky
vyspiansky / cherry-pick.md
Created February 1, 2023 09:37
Cherry-pick

Cherry-pick

  1. Get commit hash 103fe73
  2. Create branch from a specific version (tag) and name it like forward-merge-<YOUR_BRANCH>
  3. Run git cherry-pick 103fe73
  4. Resolve conflicts if needed
@vyspiansky
vyspiansky / vs-code-snippets.md
Created January 31, 2023 21:59
Visual Studio Code snippets

How to compare 2 files

code -d left.txt right.txt

Note: where in your ~/.bash_profile file

code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}
@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&gt; 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).