Skip to content

Instantly share code, notes, and snippets.

View mamedshahmaliyev's full-sized avatar

Mamed Shahmaliyev mamedshahmaliyev

View GitHub Profile
@mamedshahmaliyev
mamedshahmaliyev / docker_usefull_commands.sh
Last active August 9, 2021 06:56
Usefull commands for docker-compose and docker, supplementary material for https://adhoctuts.com/run-mulitple-databases-in-single-machine-using-docker
#####################################################################
## docker-compose commands, works with service names ################
## docker-compose will look for docker-compose.yml file by default ##
#####################################################################
docker-compose up -d # build and start all the containers
docker-compose up -d service_name # build and start specific container
# stop and remove all the containers,
# removes all the data unless the data persistence is specified
#!/bin/bash
# Define the database and root authorization details
db_host='localhost'
db_name='adhoctuts'
db_user='root'
db_pass='Adhoctuts2018#'
# Define the query to get the needed tables
table_list=$(mysql -h $db_host -u $db_user -p"$db_pass" -se "select concat(table_schema,'.',table_name) from information_schema.tables where table_schema='$db_name' and table_name not like 'tbl1' AND table_name not like '\_\_%';" $db_name | cut -f1)
#!/bin/bash
# Define the database and root authorization details
db_host='localhost'
db_name='adhoctuts'
db_user='root'
db_pass='Adhoctuts2018#'
# Define the ignore list
tmp=$(mysql -h $db_host -u $db_user -p"$db_pass" -se "select group_concat(concat(' --ignore-table=',table_schema,'.',table_name)) into @tbl from information_schema.tables where table_schema='$db_name' and table_name like '%_log';select @tbl;" $db_name | cut -f1)
#!/bin/bash
# Where to restore
db_host='localhost'
db_name='adhoctuts'
db_user='root'
db_pass='Adhoctuts2018#'
dump_file='/root/scripts/dump_ignore.sql'
@mamedshahmaliyev
mamedshahmaliyev / ssl_fix.sh
Last active March 7, 2024 13:51
Self-signed certificate issues, disable SSL verification, ignore SSL related errors etc.
####### installation of self-signed certificate into CentOS7 (RHEL) #######
mkdir -p /etc/pki/ca-trust/source/anchors
cp /path/to/self_signed_cert.crt /etc/pki/ca-trust/source/anchors/self_signed_cert.crt
chmod +x /etc/pki/ca-trust/source/anchors/self_signed_cert.crt
sudo update-ca-trust
####### installation of self-signed certificate into Ubuntu (Debian) #######
mkdir -p /usr/local/share/ca-certificates/
cp /path/to/self_signed_cert.crt /usr/local/share/ca-certificates/self_signed_cert.crt
chmod +x /usr/local/share/ca-certificates/self_signed_cert.crt
@mamedshahmaliyev
mamedshahmaliyev / forex_historical_data_truefx.py
Created August 6, 2019 18:12
Download forex historical data monthly in csv format from http://www.truefx.com (pepperstone) using python and selenium
import datetime, time, os
from dateutil.relativedelta import relativedelta
from selenium import webdriver
tmp_dir = os.path.join(os.getcwd(), 'forex')
if not os.path.isdir(tmp_dir): os.makedirs(tmp_dir)
options = webdriver.ChromeOptions();
options.add_argument("--window-size=1300,900")
options.add_experimental_option("prefs", {
@mamedshahmaliyev
mamedshahmaliyev / git_tips.md
Last active December 2, 2020 07:09
Git tips

fix ansible bug: Bitbucket_access_key list object is not an iterator (python 2.7 compat), ansible/ansible#58456

find / -type f -name "bitbucket_access_key.py" -exec sed -i "s/next(filter(lambda/next(iter(filter(lambda/g" {} +
find / -type f -name "bitbucket_access_key.py" -exec sed -i "s/\]), None/\])), None/g" {} +
@mamedshahmaliyev
mamedshahmaliyev / raspbian_selenium.sh
Last active March 18, 2024 08:17
Install selenium with chrome driver in raspbian for raspberry pi 3
apt-get install chromium-chromedriver --yes
apt-get install xvfb --yes
pip install PyVirtualDisplay xvfbwrapper selenium
echo '''
from pyvirtualdisplay import Display
from selenium import webdriver
display = Display(visible=0, size=(1024, 768))
display.start()
opts = webdriver.ChromeOptions()
@mamedshahmaliyev
mamedshahmaliyev / ssh_no_prompt_multi_hosts.sh
Last active October 15, 2019 17:51
create ssh key pair silently using ssh-keygen without prompt and ssh-copy-id to multiple hosts
# generate ssy key pair silently
yes y | ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa > /dev/null
# register public key in multiple hosts
for ip in "192.168.0.1" "192.168.0.2"; do sshpass -p 'toor' ssh-copy-id -oStrictHostKeyChecking=no "root@$ip" > /dev/null; done