Skip to content

Instantly share code, notes, and snippets.

View yanmhlv's full-sized avatar

Ian Mikhailov yanmhlv

View GitHub Profile
@yanmhlv
yanmhlv / user management.sql
Last active November 17, 2022 18:38
create user, set password, grand and revoke access to certain and all tables
CREATE USER admin; -- create user with name 'admin'
ALTER USER admin WITH PASSWORD 'hello123'; -- set password
GRANT SELECT ON users TO admin; -- give 'select' access on 'users' table to 'admin' user
REVOKE SELECT ON users FROM admin; -- revoke access on 'users' table from 'admin' user
GRANT SELECT ON ALL TABLES IN SCHEMA public TO admin; -- give access to all tables in public schema to 'admin' user
REVOKE ALL ON ALL TABLES IN SCHEMA public FROM admin; -- revoke access on all tables from 'admin' user
DROP USER admin;
@yanmhlv
yanmhlv / psql_useful_stat_queries.sql
Created August 22, 2019 20:04 — forked from anvk/psql_useful_stat_queries.sql
List of some useful Stat Queries for PSQL
--- PSQL queries which also duplicated from https://github.com/anvk/AwesomePSQLList/blob/master/README.md
--- some of them taken from https://www.slideshare.net/alexeylesovsky/deep-dive-into-postgresql-statistics-54594192
-- I'm not an expert in PSQL. Just a developer who is trying to accumulate useful stat queries which could potentially explain problems in your Postgres DB.
------------
-- Basics --
------------
-- Get indexes of tables
@yanmhlv
yanmhlv / postgres_queries_and_commands.sql
Created August 22, 2019 19:59 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@yanmhlv
yanmhlv / Makefile
Last active September 24, 2019 09:55
teamcity in docker
TEAMCITY_PWD = /opt/teamcity
.PHONY: docker-down
docker-down:
docker-compose down -v --remove-orphans
.PHONY: docker-up
docker-up: docker-down
TEAMCITY_PWD=${TEAMCITY_PWD} docker-compose up -d
FROM ubuntu:16.04
# Install bitcoind from PPA
RUN apt-get update
RUN apt-get install --yes software-properties-common
RUN add-apt-repository --yes ppa:bitcoin/bitcoin
RUN apt-get update
# install bitcoind (from PPA) and make
RUN apt-get install --yes bitcoind
@yanmhlv
yanmhlv / System Design.md
Created March 6, 2019 14:58 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
-module(gs1).
-export([start/0, loop/1]).
% simple gen server with state
start() ->
% io:format("Start ~p~n", [self()]),
% spawn(fun loop/0).
InitialState = [],
spawn(?MODULE, loop, [InitialState]).
@yanmhlv
yanmhlv / gist:a608d7a342cd00b839147d15dbbf9dcd
Created September 15, 2017 12:07 — forked from the42/gist:1956518
GZip encoding for GO V1 using custom responsewriter
package main
import (
"compress/gzip"
"io"
"net/http"
"strings"
)
type gzipResponseWriter struct {
package main
import (
"bytes"
"errors"
"html/template"
"net/http"
"path/filepath"
)
@yanmhlv
yanmhlv / bash-cheatsheet.sh
Created April 30, 2017 13:22 — forked from bilun167/bash-cheatsheet.sh
Bash CheatSheet for UNIX Systems
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04