Skip to content

Instantly share code, notes, and snippets.

View avkosme's full-sized avatar
👨‍💻
in k8s clouds

Andrei Kostiuchenko avkosme

👨‍💻
in k8s clouds
View GitHub Profile
@avkosme
avkosme / gist:38e74e8bdf3ea749398deabb60484513
Created March 22, 2018 02:27
Displaying a remote SSL certificate details using CLI tools
echo | openssl s_client -showcerts -servername www.api.apline.pro -connect www.api.apline.pro:443 2>/dev/null | openssl x509 -inform pem -noout -text
@avkosme
avkosme / gist:0313739f642cf3399b72c7d0f80e0b12
Created April 27, 2018 05:55
Топ занимаемых данных в таблицах Mysql
SELECT
table_schema as `Database`,
table_name AS `Table`,
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM information_schema.TABLES
ORDER BY (data_length + index_length) DESC;
@avkosme
avkosme / sql
Created May 15, 2018 14:11
sql procedure
drop table if exists appFilesX;
create table appFilesX like app_files;
drop function if exists allUpdate;
create function allUpdate(pathGroup varchar(255) charset utf8 collate utf8_unicode_ci, fileId INT) returns int
@avkosme
avkosme / postgres backup-restore
Last active November 18, 2019 11:27
Postgres backup-restore
pg_dump -U postgres -O -Fc dbname > dumpfile
Here we used the following options:
-U to specify which user will connect to the PostgreSQL database server.
-W or --password will force pg_dump to prompt for a password before connecting to the server.
-F is used to specify the format of the output file, which can be one of the following:
p – plain-text SQL script
c – custom-format archive
d – directory-format archive
@avkosme
avkosme / gist:9d775534514305ba535a232f858319e4
Created August 28, 2018 23:17
Resolve postgres permission denied for relation
Connect to the right database first, then run:
$ GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO user;
@avkosme
avkosme / bash script to throw an error
Created September 4, 2018 21:18
Configure the bash script to throw an error if any of the commands within it return a non-zero exit code.
#!/bin/bash
set -o errexit
apt-get update
apt-get upgrade -y
apt-get install -y git wget sudo
git clone https://github.com/facebook/osquery.git
cd /osquery
git checkout 1.0.3
sudo vim /etc/default/grub
GRUB_CMDLINE_LINUX="ipv6.disable=1 rd.lvm.lv=cl_workstation/root rd.lvm.lv=cl_workstation/swap loglevel=7 systemd.log_level=debug"
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
@avkosme
avkosme / gist:bd22d630ea1728d4a3b831f2ecafd25b
Created September 28, 2018 12:12
getParameterByName from url
function getParameterByName(name, url) {
name = name.replace(/[\[\]]/g, "\\$&");
let regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return '';
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
export const toQueryString = (params) => {
if (!params) {
return ''
}
if (!Object.keys(params).length) {
return ''
}
@avkosme
avkosme / gist:bd79d24862db48959bc0fd87d08473b1
Created November 1, 2018 04:24
firefox theme gtk override
widget.content.gtk-theme-override string Adwaita