Skip to content

Instantly share code, notes, and snippets.

@altif227
altif227 / postgres_queries_and_commands.sql
Created November 21, 2018 06:38 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@altif227
altif227 / Install bash-completion on Amazon Linux
Created November 24, 2018 19:11 — forked from dasgoll/Install bash-completion on Amazon Linux
Install bash-completion on Amazon Linux
## Install bash-completion on Amazon Linux
wget http://www.caliban.org/files/redhat/RPMS/noarch/bash-completion-20060301-1.noarch.rpm
rpm -ivh bash-completion-20060301-1.noarch.rpm
. /etc/bash_completion
@altif227
altif227 / accept_known_hosts.sh
Created November 28, 2018 13:22 — forked from FelikZ/accept_known_hosts.sh
Fix known_hosts file "Jenkins Host key verification failed"
#!/bin/bash
for domain in "github.com" "bitbucket.org"; do
echo $domain
sed -i "/$domain/d" ~/.ssh/known_hosts
line=$(ssh-keyscan $domain,`nslookup $domain | awk '/^Address: / { print $2 ; exit }'`)
echo $line >> ~/.ssh/known_hosts
done
@altif227
altif227 / installAndConfigureTomcat8.sh
Created December 10, 2018 13:47
Install and configure Tomcat8 on an Amazon Linux AMI using Java OpenJDK 1.8 that starts on reboot.
#!/bin/bash
mkdir /opt/tomcat
yum update -y
yum install java-1.8.0-openjdk-devel httpd24 git -y
service httpd start
chkconfig httpd on
yum remove java-1.7.0-openjdk -y
# calling the version may ensure that java recognizes 1.8 as the new defaut
java -version
echo "JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk/jre" | \
@altif227
altif227 / autopgsqlbackup
Created April 1, 2019 10:21 — forked from matthewlehner/autopgsqlbackup
Auto PostgreSQL backup script.
#!/bin/bash
#
# PostgreSQL Backup Script Ver 1.0
# http://autopgsqlbackup.frozenpc.net
# Copyright (c) 2005 Aaron Axelsen <[email protected]>
#
# This script is based of the AutoMySQLBackup Script Ver 2.2
# It can be found at http://sourceforge.net/projects/automysqlbackup/
#
# The PostgreSQL changes are based on a patch agaisnt AutoMySQLBackup 1.9
@altif227
altif227 / .vimrc
Created May 18, 2019 23:26 — forked from simonista/.vimrc
A basic .vimrc file that will serve as a good template on which to build.
" Don't try to be vi compatible
set nocompatible
" Helps force plugins to load correctly when it is turned back on below
filetype off
" TODO: Load plugins here (pathogen or vundle)
" Turn on syntax highlighting
syntax on
@altif227
altif227 / Apache Tomcat 8 Start stop script init.d script
Created June 27, 2019 15:57 — forked from miglen/Apache Tomcat 8 Start stop script init.d script
Apache Tomcat init script (or startup/controll script). Works fine for version 7/8. Read the comments for release history. Feel free to modify, copy and give suggestions. (c) GNU General Public License
#!/bin/bash
#
# description: Apache Tomcat init script
# processname: tomcat
# chkconfig: 234 20 80
#
#
# Copyright (C) 2014 Miglen Evlogiev
#
# This program is free software: you can redistribute it and/or modify it under
@altif227
altif227 / export_db_structure.sh
Created July 3, 2019 09:17 — forked from dantheman213/export_db_structure.sh
Batch backup and export your Postgres or PostgreSQL table schemas and stored functions or procedures into individual *.sql files --the easy way!
#!/bin/sh
# AUTHOR
# DANIEL E. GILLESPIE (2016)
# https://github.com/dantheman213
# DESCRIPTION
# Export your app's table schemas and stored functions from a PostgreSQL
# database into individual *.sql files for easy management and source control.
@altif227
altif227 / README.md
Created August 22, 2019 11:33 — forked from leonardofed/README.md
A curated list of AWS resources to prepare for the AWS Certifications


A curated list of AWS resources to prepare for the AWS Certifications

A curated list of awesome AWS resources you need to prepare for the all 5 AWS Certifications. This gist will include: open source repos, blogs & blogposts, ebooks, PDF, whitepapers, video courses, free lecture, slides, sample test and many other resources.


@altif227
altif227 / postgres-cheatsheet.md
Created October 2, 2019 05:32 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)