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 / 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 / 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;
@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 / git_delete_tag_local_and_remote.sh
Created October 9, 2019 13:07
Git: Delete local and remote tag
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@CHERTS
CHERTS / zbx_440_opdata_remove_bracket.patch
Created October 14, 2019 05:31
Patch for Zabbix v4.4.0 to remove bracket in operational data
--- frontends/php/app/views/monitoring.widget.problems.view.php.orig 2019-10-14 01:13:02.104862978 -0400
+++ frontends/php/app/views/monitoring.widget.problems.view.php 2019-10-14 01:23:01.615655216 -0400
@@ -197,7 +197,7 @@
];
if ($show_opdata == OPERATIONAL_DATA_SHOW_WITH_PROBLEM && $opdata) {
- $problem_link = array_merge($problem_link, [' (', $opdata, ')']);
+ $problem_link = array_merge($problem_link, [' ', $opdata]);
}