Skip to content

Instantly share code, notes, and snippets.

View CHERTS's full-sized avatar

Mikhail Grigorev CHERTS

View GitHub Profile
@CHERTS
CHERTS / mysite.js
Last active November 5, 2017 17:19
Image resize with nginx (this is replace phpThumb script)
// Image resize with nginx (this is replace phpThumb script)
function escapeRegExp(str) {
return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
}
function replaceAll(str, find, replace) {
return str.replace(new RegExp(escapeRegExp(find), 'g'), replace);
}
@CHERTS
CHERTS / how-to-install-telegram-send
Last active August 29, 2022 11:19
Fail2ban + Telegram using telegram-send
# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.9 (jessie)
Release: 8.9
Codename: jessie
Installing telegram-send
# pip install telegram-send
@CHERTS
CHERTS / nginx.conf
Last active July 29, 2023 13:39
Nginx best config (base config) for Debian
user www-data;
worker_processes auto;
worker_cpu_affinity auto;
worker_rlimit_nofile 10000;
worker_shutdown_timeout 30;
pid /run/nginx.pid;
events {
worker_connections 1024;
# Для Linux 2.6+ - epool, Для FreeBSD - kqueue
@CHERTS
CHERTS / mysite.conf
Created December 8, 2017 06:08
Minimal Nginx config file to WordPress
server {
listen XX.XX.XX.XX:80;
server_name mysite.ru;
root /var/www/mysite.ru;
index index.php index.html index.htm;
error_log /var/log/nginx/mysite.ru_error.log;
access_log /var/log/nginx/mysite.ru_access.log main;
set $fastcgipass unix:/var/lib/php5-fpm/mysite.sock;
@CHERTS
CHERTS / nc_on_bash.sh
Last active June 6, 2018 11:07
Implementing netcat in bash
#!/bin/bash
SERVER_ADDR=$1
SERVER_PORT=$2
_command_exists() {
type "${1}" &> /dev/null
}
_nc() {
@CHERTS
CHERTS / openssl_get_sha256_fingerprint.sh
Created December 24, 2018 05:19
OpenSSL get sha256 ssl fingerprint
MYSITE=torproject.org && openssl s_client -servername ${MYSITE} -connect ${MYSITE}:443 </dev/null 2>/dev/null | openssl x509 -text | sed -n -e '/BEGIN\ CERTIFICATE/,/END\ CERTIFICATE/p' | openssl x509 -fingerprint -sha256 | head -1 | cut -f2 -d'=' | sed 's,:,,g' | tr '[:upper:]' '[:lower:]'
@CHERTS
CHERTS / proxysql-binlogreader
Last active March 15, 2019 11:42
proxysql-binlogreader init.d script for debian or ubuntu
#!/bin/bash
#
### BEGIN INIT INFO
# Provides: proxysql-binlogreader
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: ProxySQL Binlog Reader for MySQL
### END INIT INFO
@CHERTS
CHERTS / zbx_440alfa3_opdata_one_line.patch
Last active October 3, 2019 07:28
Show problems and operational data in Zabbix 4.4.0-alfa3 as one line
--- ./frontends/php/include/blocks.inc.php.orig 2019-09-27 20:57:02.214919180 +0300
+++ ./frontends/php/include/blocks.inc.php 2019-09-27 20:57:14.583818457 +0300
@@ -732,7 +732,6 @@
_('Info'),
_('Host'),
_('Problem'),
- $show_opdata ? _('Operational data') : null,
_('Duration'),
_('Ack'),
_('Actions'),
@CHERTS
CHERTS / mysql_import.sh
Created September 23, 2019 11:50
Logging mysql import error
mysql -u root -p db_name < dumpfilename.sql > /var/tmp/mysqldump.log 2>&1
or create file mysql-import.sh:
#!/bin/bash
mysql -u root -p'password' -h hostname db_name << EOF
CREATE DATABASE dbname;
USE dbname;
SET foreign_key_checks=0;
SOURCE dbdumpname.sql;
@CHERTS
CHERTS / mysql_import.sh
Last active September 23, 2019 11:52
Logging mysql import error
1) Run:
mysql -u root -p db_name < dumpfilename.sql > /var/tmp/mysqldump.log 2>&1
2) Or create file mysql-import.sh:
#!/bin/bash
mysql -u root -p'password' -h hostname db_name << EOF
CREATE DATABASE dbname;
USE dbname;
SET foreign_key_checks=0;