Skip to content

Instantly share code, notes, and snippets.

View gh0st026's full-sized avatar
🙃

Ian Smith gh0st026

🙃
View GitHub Profile
@gh0st026
gh0st026 / clear_docker.sh
Created September 25, 2018 08:30
Removes everything from docker. Containers, volumes, networks, images etc.
sudo docker stop $(sudo docker ps -aq)
sudo docker rm $(sudo docker ps -aq)
sudo docker network prune -f
sudo docker rmi -f $(sudo docker images --filter dangling=true -qa)
sudo docker volume rm $(sudo docker volume ls --filter dangling=true -q)
sudo docker rmi -f $(sudo docker images -qa)
@gh0st026
gh0st026 / aws_copy_file.sh
Created October 15, 2018 09:16
Download / Upload a file on AWS EC2
# Download File
scp -i ec2key.pem username@ec2ip:/path/to/file .
# Upload File
scp -i ec2key.pem path/to/file username@ec2ip:/path/to/file
@gh0st026
gh0st026 / migrate_iptables.sh
Last active October 15, 2018 09:22
Basic Commands for migrating iptables rules
# View iptables rules
sudo iptables -S
# Export iptables Rules
sudo iptables-save > iptables-export
# Import iptables rules
sudo iptables-restore < iptables-export
# Persist rules on reboot on ubuntu
@gh0st026
gh0st026 / export_postgre_docker.sh
Last active January 30, 2019 21:17
export PostGre SQL from docker container
CONTAINER_NAME=Container
DUMP_FILE=dump.sql
sudo docker exec -u postgres ${CONTAINER_NAME} pg_dumpall -c > ${DUMP_FILE}
@gh0st026
gh0st026 / import_postgre_docker.sh
Last active January 30, 2019 21:18
import PostGRE SQL into Docker Container
CONTAINER_NAME=Container
DUMP_FILE=dump.sql
cat ${DUMP_FILE} | sudo docker exec -i ${CONTAINER_NAME} psql -U postgres
@gh0st026
gh0st026 / connect_docker_container.sh
Last active January 30, 2019 21:17
Connect To a Docker Container
CONTAINER_NAME=Container
sudo docker exec -it ${CONTAINER_NAME} /bin/bash
@gh0st026
gh0st026 / list_docker_container.sh
Created January 30, 2019 21:13
List All Docker Containers
sudo docker ps
@gh0st026
gh0st026 / docker_export_postgre_table.sh
Last active February 13, 2023 02:15
Dump PostgreSQL Table in docker container as CSV file
CONTAINER="name"
DB="Db name"
TABLE="Table Name"
FILE="file.csv"
sudo docker exec -u postgres ${CONTAINER} psql -d ${DB} -c "COPY ${TABLE} TO STDOUT WITH CSV HEADER " > ${FILE}
# change setup_11.x to the desired version. IE: setup_8.x for v8
curl --silent --location https://rpm.nodesource.com/setup_11.x | sudo bash -
sudo yum -y install nodejs
node --version

Keybase proof

I hereby claim:

  • I am gh0st026 on github.
  • I am gh0st026 (https://keybase.io/gh0st026) on keybase.
  • I have a public key ASB-XLJdmlIT8fy8pqJ5yDCeMPU92XPEB20fDQTyeRvaewo

To claim this, I am signing this object: