Skip to content

Instantly share code, notes, and snippets.

View YouSysAdmin's full-sized avatar
🤪

Oleksii Samoliuk YouSysAdmin

🤪
View GitHub Profile
@YouSysAdmin
YouSysAdmin / fix.sh
Created March 25, 2025 20:39
Fix for using MacOS as remote DOCKER_HOST
# Context:
# make sure the URL is valid, and Docker 18.09 or later is installed on the remote host.
# zsh:1: command not found: docker
# Add /usr/local/bin to PATH for SSH session
echo 'PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin' >> ~/.ssh/environment
# Permit set user environment for SSH session
sudo sh -c 'echo "PermitUserEnvironment PATH" >> /private/etc/ssh/sshd_config'
@YouSysAdmin
YouSysAdmin / theme.yml
Created March 2, 2025 09:24 — forked from r-darwish/theme.yml
Alacritty One Dark Theme
colors:
# Default colors
primary:
background: '0x1e2127'
foreground: '0xabb2bf'
# Bright and dim foreground colors
#
# The dimmed foreground color is calculated automatically if it is not present.
@YouSysAdmin
YouSysAdmin / schema_auto_increment_columns.sql
Created December 2, 2024 11:28 — forked from bennadel/schema_auto_increment_columns.sql
Looking For Database Performance Bottlenecks And Optimizations Using The Sys Schema In MySQL 5.7
/**
* Find the amount of auto-increment "space" has been used. This may can help identify
* tables that are running out of available ID values.
*/
SELECT
t.table_name,
t.column_name,
-- The highest possible ID that can be created with this data-type.
t.max_value,
-- The last ID created in this table.
@YouSysAdmin
YouSysAdmin / print.go
Last active September 17, 2024 21:29
// Database Information about RDS instance
type Database struct {
// Database identifier
Identifier string
// Database ARN
Arn string
// Database engine (mysql2, postgres, etc.)
Engine string
// Database engine version
EngineVersion string
@YouSysAdmin
YouSysAdmin / mysql-memoryusage.sh
Created August 4, 2023 19:55
Script to get information about used memory by a MySQL server
#!/bin/sh
# you might want to add some user authentication here
mysql -e "show variables; show status" | awk '
{
VAR[$1]=$2
}
END {
MAX_CONN = VAR["max_connections"]
MAX_USED_CONN = VAR["Max_used_connections"]
BASE_MEM=VAR["key_buffer_size"] + VAR["query_cache_size"] + VAR["innodb_buffer_pool_size"] + VAR["innodb_additional_mem_pool_size"] + VAR["innodb_log_buffer_size"]
@YouSysAdmin
YouSysAdmin / remove_old_builds.sql
Created March 28, 2021 07:34 — forked from david-zw-liu/remove_old_builds.sql
Keep 1000 builds per repos for DroneCI (sqlite3 version >= 3.25 required)
-- Thank @sbengo to figure out foreign_keys constraints is defaults to false in sqlite
-- Enable to delete logs by cascading delete
PRAGMA foreign_keys = ON;
WITH n_build_ids_per_repo as (
SELECT build_id
FROM (
SELECT
build_id,
build_repo_id,
@YouSysAdmin
YouSysAdmin / run-before-shutdown.service
Created October 28, 2020 07:54
Systemd - Run before shutdown/reboot
# systemd unit file
# /etc/systemd/system/run-before-shutdown.service
# TimeoutStartSec - set a timeout for your task or set "0" to disable.
# When the timeout is turned off and the task "hangs",
# the process will never be interrupted and the system
# shutdown will stop
# Before - Specify the services before which the task should run
# after add unit file in systemd/system catalogue, "run systemctl daemon-reload"
# and enable new service "systemctl enable run-before-shutdown.service"
package main
import (
"bytes"
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
@YouSysAdmin
YouSysAdmin / postgresql_cron_env.sh
Created August 26, 2019 14:26
execute SQL query from cron
# .cron_env
# Save to /root directory, chmod 400/600
export DB_HOST="127.0.0.1"
export DB_USER="postgres"
export DB_PASSWORD="postgres"
# cron
59 23 * * * . /root/.cron_env; /usr/bin/psql_super_puper.sh $DB_USER $DB_PASSWORD $DB_HOST "select * from ololo"