Skip to content

Instantly share code, notes, and snippets.

View shahedhossain's full-sized avatar

Md Shahed Hossain shahedhossain

View GitHub Profile
@shahedhossain
shahedhossain / postgresql_with_statement_for_select_and_update.sql
Created December 22, 2022 03:51
PostgreSQL With Statement for Select & Update Query
WITH ou_commissions AS (
SELECT
code "org_unit_code",
commissions->>'type' "commission_type",
commissions->>'value' "commission_value",
commissions->>'priceField' "price_field",
commissions->>'product_code' "product_code",
commissions->>'product_name' "product_name",
commissions->>'product_slug' "product_slug",
commissions->>'sameRateForAgencyBranches' "same_rate",
@shahedhossain
shahedhossain / postgresql_prepared_statement_with_json_and_for_loop.sql
Last active December 18, 2022 16:28
PostgreSQL Prepared Statement for Select & Update Query
DO $BODY$
DECLARE
p_select_query varchar;
p_update_query varchar;
p_agency_code varchar;
p_agency_codes jsonb;
p_commissions jsonb;
BEGIN
-- fetch agency codes
-- -------------------------------------------------------------------------
@shahedhossain
shahedhossain / iterate_oracle_sequence_from_bash.sh
Last active December 23, 2018 09:05
Iterate Oracle Sequence From Bash
sch='ACADEMIA_DEV';seq='ACADEMIA_SEQ';\
printf '\n\033[0;33mDo you iterate \033[0m %s \033[0;33m?\033[0m\n' "$seq";\
select y in 'yes' 'no';do case $y in 'yes') break;; 'no') break;;esac;done;\
printf '\nYour option is: \033[0;32m%s\033[0m' "$y";if [ "$y" == "yes" ];\
then printf '\n\033[0;33mEnter the no.of iteration: \033[0m';read itr;printf \
'\033[0;33mEnter the password of\033[0m %s\033[0m\033[0;33m: \033[0m' "$sch";\
read -s pwd;(cat<<EOF
CONN $sch/$pwd;
DECLARE
VISIT_NO NUMBER;
@shahedhossain
shahedhossain / oracle_plsql_script_ability_by_bash.sh
Last active December 23, 2018 01:37
Oracle PLSQL Script Ability By Bash
sch='ACADEMIA_DEV';seq='ACADEMIA_SEQ';\
printf '\n\033[0;33mDo you iterate \033[0m %s \033[0;33m?\033[0m\n' "$seq";\
select y in 'yes' 'no';do case $y in 'yes') break;; 'no') break;;esac;done;\
printf '\nYour option is: \033[0;32m%s\033[0m' "$y";if [ "$y" == "yes" ];\
then printf '\n\033[0;33mEnter the no.of iteration: \033[0m';read itr;printf \
'\033[0;33mEnter the password of\033[0m %s\033[0m\033[0;33m: \033[0m' "$sch";\
read -s pwd;(cat<<EOF
CONN $sch/$pwd;
DECLARE VISIT_NO NUMBER;
BEGIN
@shahedhossain
shahedhossain / sqlplus_bash_script_redirect_input.sh
Created December 10, 2018 13:09
Oracle SQLPlus Bash Script Redirect Input
# any where of the bash file can be placed this script
SYSPWD=oracle;\
echo "Oracle SQLPlus Multi-Line Input";\
(cat<<EOF
drop user academia_dev cascade;
create user academia_dev identified by academia_dev;
grant connect, resource, dba to academia_dev;
exit;
EOF
)|sqlplus -s sys/$SYSPWD as sysdba;\
@shahedhossain
shahedhossain / fedora_ssh_client_public_key_authentication.sh
Last active November 16, 2020 05:08
Fedora SSH Client Public Key Authentication
#################### CLIENT SIDE ####################
# generating a new ssh key and adding it to the ssh client
# https://gist.github.com/shahedhossain/7d91028ba1eb9c56049ea421a12e76fd
# ssh key generation for chorke
ssh-keygen -t rsa -b 4096 -C "user@cdn.chorke.org"
# Generating public/private rsa key pair.
# Enter a file in which to save the key (/Users/user/.ssh/id_rsa): [Press enter]
# Enter passphrase (empty for no passphrase): [Type a passphrase]
# Enter same passphrase again: [Type passphrase again]
@shahedhossain
shahedhossain / docker_mssql_server_2017_express.sh
Last active November 22, 2017 18:34
SQL Server 2017 Express Edition docker images for MacOS
# load microsoft/mssql-server-linux image
docker pull microsoft/mssql-server-linux
# mssql dockers image creation
docker run --name="mssql" -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=pa55w0rd" -e "MSSQL_PID=Express" -p 1433:1433 microsoft/mssql-server-linux
# sqlcmd access to mssql
docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P pa55w0rd
# start stop docker image
@shahedhossain
shahedhossain / oracle_schema_create_export_import.sh
Last active January 4, 2019 03:53
Oracle schema create, grant, export and import
#login as sysdba using os auth
sqlplus "/as sysdba"
exit
#login as sysdba using sys/password
sqlplus sys/password as sysdba
exit
#login as sysdba using sys/password@sid
sqlplus sys/password@cki as sysdba
@shahedhossain
shahedhossain / macos_sierra_chorke_ssh.sh
Last active November 28, 2017 05:34
SSH Key generation, add Key to SSH Agent
# generating a new ssh key and adding it to the ssh agent
# https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/
# ssh key generation for chorke
ssh-keygen -t rsa -b 4096 -C "your_email@chorke.org"
# Generating public/private rsa key pair.
# Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
# Enter passphrase (empty for no passphrase): [Type a passphrase]
# Enter same passphrase again: [Type passphrase again]
@shahedhossain
shahedhossain / oracle_user_bash_profile.sh
Created July 26, 2017 04:23
Enterprise Linux oracle user bash profile for Oracle 11gR2
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH