Skip to content

Instantly share code, notes, and snippets.

View YouSysAdmin's full-sized avatar
🤪

Oleksii Samoliuk YouSysAdmin

🤪
View GitHub Profile
@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"
package main
import (
"fmt"
"net/http"
"github.com/julienschmidt/httprouter"
)
func main() {
// config/initializers/appconfig.rb
APP_CONFIG = YAML.load_file(Rails.root.join('config/app_config.yml'))[Rails.env]
@YouSysAdmin
YouSysAdmin / verse.md
Last active March 5, 2016 23:20
Стишок :)

Я узнал, что у меня
Есть огромная семья
Puma, Rails, Redis,
Linux, Cisco,
Сиськи, печенюшки.
Даже Twitter у меня
как огромная семья
Это все мое родное
Это воздух для меня,
Всех люблю на свете я!

@YouSysAdmin
YouSysAdmin / ogv2gif.sh
Created October 21, 2015 12:33
Convert OGV to GIF
mplayer -ao null out.ogv -vo jpeg:outdir=output
convert output/* output.gif
convert output.gif -fuzz 10% -layers Optimize optimised.gif