Skip to content

Instantly share code, notes, and snippets.

View byk0t's full-sized avatar

Pavel K. byk0t

  • Belarus, Spain, Europe, Earth
View GitHub Profile
@byk0t
byk0t / query.sql
Last active December 15, 2020 20:11
PostgreSQL, Get comma separated list of tables based on a table name.
-- select table by name
SELECT string_agg(table_name, ', ')
FROM information_schema.tables
WHERE table_schema='public'
AND table_type='BASE TABLE'
AND table_name like 't_%'
-- select only empty tables
select
string_agg(relname, ', ')
@byk0t
byk0t / solution.txt
Created November 29, 2020 20:38
Resize (by width) all images in the folder by single command (using imagemagick convert)
for file in *.jpg; do convert $file -resize 1000 $file; done
@byk0t
byk0t / solution.txt
Created July 1, 2020 20:08
How to connect to mongodb in docker container from localhost
# sample command from dockerhub
docker run --name some-mongo -d mongo:tag
# but to make mongo available from localhost you should change this command a bit
docker run --name some-mongo -p 27017:27017 -d mongo:tag
# so now you can connect to the mongo using the next command
mongo -host localhost -port 27017
@byk0t
byk0t / postgres-connect.txt
Created June 1, 2020 10:09
Postgres: allow connections for not OS users
sudo nano /etc/postgresql/12/main/pg_hba.conf
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
@byk0t
byk0t / solution.sql
Created April 13, 2020 07:16
MySQL GROUP_CONCAT max output lengh
# Check the existing value
SHOW VARIABLES LIKE '%group_concat%';
# Setup a new one
SET SESSION group_concat_max_len = 100500;
@byk0t
byk0t / bin2dec.html
Last active September 28, 2019 12:58
Simple HTML form with binary to decimal converter
<!DOCTYPE html>
<html>
<head>
<title>bin to dec</title>
</head>
<body>
<div>
<label for="bin">Enter binary number: </label>
<input type="text" name="bin" id="bin"><br/>
<span>Decimal: <span id="dec"></span></span>
@byk0t
byk0t / aws-only-scan-table-policy.json
Created September 5, 2019 12:53
AWS IAM policy that Allows Only Scan to a Specific DynamoDB Table
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "SpecificTable",
"Effect": "Allow",
"Action": [
"dynamodb:Scan"
],
"Resource": "arn:aws:dynamodb:eu-central-1:default:table/tableName"
@byk0t
byk0t / run-avd-cli.txt
Last active May 21, 2019 13:41
Run android virtual device (avd) from command line
1. Check existed avds
emulator -list-avds
2. Run (in my case it is Nexus_5X_API_28_x86)
emulator -avd Nexus_5X_API_28_x86
@byk0t
byk0t / solution.sh
Created March 29, 2019 10:00
Solution for Unable to load script from assets ‘index.android.bundle’
rm -rf android/app/build/outputs/apk/debug/*
@byk0t
byk0t / docker-compose.yml
Last active January 26, 2024 16:08
Docker compose for odoo:14 and PostgreSQL:13
version: '3'
services:
db:
image: postgres:13
volumes:
- db-data:/var/lib/postgresql/data/pgdata
ports:
- 5432:5432/tcp
environment:
- POSTGRES_PASSWORD=odoo