Skip to content

Instantly share code, notes, and snippets.

View besteffects's full-sized avatar

Vitalii S besteffects

  • Altinity
  • Canada
View GitHub Profile
# List of running services
systemctl --type=service --state=running
# Stop service
sudo service name stop
# Remove service from startup
systemctl disable service name
# Get text from an element by CSS selector:
var element = document.querySelector('select[name=someName]>option:nth-child(1)');
var text = element.innerText || element.textContent;
element.innerHTML = text;
# Find an element by text some_text with ignoring text formatting
option_el = driver.find_element(SelectBy.XPATH, f"//option[contains(.,'{some_text}')]").click()
# split text up to specific char (prints the first part)
sep = 'RAM'
select table, disk_name, partition, bytes_on_disk from system.parts order by bytes_on_disk desc
select table, disk_name, partition, bytes_on_disk from system.parts where table LIKE '%node0%' order by bytes_on_disk desc
create TABLE sl1 (id UInt64, d Date, s String, x MATERIALIZED sleepEachRow(0.5)) Engine=ReplicatedMergeTree ORDER BY id PARTITION BY toYYYYMM(d)
insert into table sl1 select number, number+1, number+2 from numbers(100)
ATTACH TABLE attached (id UInt64, d Date, s String, x MATERIALIZED sleepEachRow(2)) Engine=ReplicatedMergeTree ORDER BY id PARTITION BY toYYYYMM(d);
insert into attached select number, number+1, number+2 from numbers(10)
CREATE TABLE to_detach
dpkg --list
sudo apt-get remove package_name # Then remove the given package
sudo apt-get purge package_name # Purge any related code
sudo apt-get autoremove # Then Autoremove
sudo apt-get clean # Finally, do a clean so you check everything is correctly removed
@besteffects
besteffects / metrics_metrics1
Last active March 21, 2022 23:02 — forked from den-crane/metrics_metrics1
order by (metric, time) VS order by (time, metric)
create table metrics (metric UInt32, val Float64, time DateTime) engine = MergeTree()
partition by toYYYYMMDD(time)
order by (metric, time)
create table metrics (metric UInt32, val Float64, time DateTime) engine = ReplicatedMergeTree('/clickhouse/{cluster}/tables/{shard}/{database}/{table}', '{replica}') partition by toYYYYMMDD(time) order by (metric, time)
insert into metrics select number%4999, rand(), (toDateTime(today())+number%2880*30) from numbers(30000000); on node 1
insert into metrics select number%4999, rand(), (toDateTime(today())+number%2880*30) from numbers(50000000); on node 2
insert into metrics select number%4999, rand(), (toDateTime(today())+number%2880*30) from numbers(100000000);
CREATE TABLE events_local
(
created_at_date Date DEFAULT toDate(created_at),
sign Int8,
customer_id UInt64,
id UInt64,
account_id UInt64,
created_at DateTime,
uuid Nullable(FixedString(16)),
type Nullable(Int8)
kubectl config --help # get config help
brew install int128/kubelogin/kubelogin # install kubelogin on Linux https://github.com/int128/kubelogin#setup
kubectl get pods #
kubectl config current-context # show current context
kubectl config use-context <my context> # use a context
kubectl config get-contexts
export KUBECONFIG=$KUBECONFIG:config-filename # set path to configfile
cp config-name ~/.kube/config # set config file as default from a folder with a config file. Valid file with the latest changes should be copied
kubectl get pods --context=aws-dev-tenant-a # get pods from a specified context
create database node0;
CREATE TABLE node0.table0
(
`a` Int64,
`b` Int64,
`c` Int64,
`d` String
)
Engine = ReplicatedMergeTree('/clickhouse/{cluster}/tables/{shard}/{database}/{table}', '{replica}')
PARTITION BY a % 2
Query that will be executed n seconds:
select sleepEachRow(1) from numbers(40)
Kill a query process:
KILL QUERY WHERE query_id='{$queryId}'
SELECT number, sleepEachRow(1)
FROM system.numbers
LIMIT 60
@besteffects
besteffects / tinyLog.txt
Last active July 26, 2021 12:26
ClickHouseTinyLog
SET compile_aggregate_expressions = 1;
SET min_count_to_compile_aggregate_expression = 0;
SELECT 'Test unsigned integer values';
DROP TABLE IF EXISTS test_table_unsigned_values;
CREATE TABLE test_table_unsigned_values
(
id UInt64,