Skip to content

Instantly share code, notes, and snippets.

@aradhell
aradhell / postgres_queries_and_commands.sql
Created January 23, 2022 11:29 — 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%'
@aradhell
aradhell / siege_examples.sh
Created August 12, 2020 00:50 — forked from rob-murray/siege_examples.sh
Siege examples
# Basic example
siege -t60s -c20 -d10 'http://robertomurray.co.uk/'
# Basic auth;
auth=$(echo -n 'username:password' | openssl base64)
siege -t60s -c20 -d10 --header="Authorization:Basic $auth" 'https://staging.a-hostname.co.uk/'
#!/bin/sh
SITE=xxxx
service openvpnas stop
cd /etc/letsencrypt/live/$SITE
/usr/local/openvpn_as/scripts/sacli --key "cs.priv_key" --value_file "privkey.pem" ConfigPut
/usr/local/openvpn_as/scripts/sacli --key "cs.cert" --value_file "fullchain.pem" ConfigPut
/usr/local/openvpn_as/scripts/sacli --key "cs.ca_bundle" --value_file "chain.pem" ConfigPut
#!/bin/bash
export SEMVER_LAST_TAG=$(git describe --abbrev=0 --tags | cat | tr -d 'v' 2>/dev/null)
export SEMVER_RELEASE_LEVEL=$(git log --oneline -1 --pretty=%B | cat | tr -d '\n' | cut -d "[" -f2 | cut -d "]" -f1)
#curl -o /tmp/hub.tgz https://github.com/github/hub/releases/download/v2.2.9/hub-linux-arm64-2.2.9.tgz
#tar -xvzf /tmp/hub.tgz -C /tmp
if [ -z $SEMVER_LAST_TAG ]; then
>&2 echo "No tags defined"
@aradhell
aradhell / semver.sh
Last active May 6, 2020 11:45 — forked from lxhunter/semver.sh
Automated semantic versioning for travis-ci or any other ci
#!/bin/bash
export SEMVER_LAST_TAG=$(git describe --tags `git rev-list --tags --max-count=1` 2>/dev/null)
export SEMVER_RELEASE_LEVEL=$(git log --oneline -1 --pretty=%B | cat | tr -d '\n' | cut -d "[" -f2 | cut -d "]" -f1)
#curl -o /tmp/hub.tgz https://github.com/github/hub/releases/download/v2.2.9/hub-linux-arm64-2.2.9.tgz
#tar -xvzf /tmp/hub.tgz -C /tmp
if [ -z $SEMVER_LAST_TAG ]; then
>&2 echo "No tags defined"
@aradhell
aradhell / add_travis_ip_to_ec2_sg
Created December 20, 2019 11:14
bash script to add ip addresses from json list to ec2 security group
#!/bin/sh
#AWS_IP=$(curl https://dnsjson.com/nat.gce-us-central1.travisci.net/A.json)
curl https://dnsjson.com/nat.gce-us-central1.travisci.net/A.json | jq -r '.results.records[]' | while read id ; do
aws ec2 authorize-security-group-ingress --region eu-west-1 --group-name sg-group-name \
--protocol tcp --port 3306 \
--cidr "${id}"/32
done
curl https://dnsjson.com/nat.gce-us-east1.travisci.net/A.json | jq -r '.results.records[]' | while read id ; do
@aradhell
aradhell / swap.config
Created October 26, 2019 20:22
add swap memory to elastic beanstalk
commands:
create_pre_dir:
command: "mkdir /opt/elasticbeanstalk/hooks/appdeploy/pre"
ignoreErrors: true
files:
"/opt/elasticbeanstalk/hooks/appdeploy/pre/00_setup_swap.sh":
mode: "000755"
owner: root
group: root
content: |
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## Build generated
build/
DerivedData/
## Various settings
*.pbxuser
@aradhell
aradhell / renewOpenVpnSSL.sh
Last active June 11, 2019 12:51
certbot renew openvpn access server SSL
#!/bin/sh
SITE=vpns.xx.net
cd /etc/letsencrypt/live/$SITE
/usr/local/openvpn_as/scripts/sacli --key "cs.priv_key" --value_file "privkey.pem" ConfigPut
/usr/local/openvpn_as/scripts/sacli --key "cs.cert" --value_file "fullchain.pem" ConfigPut
cat fullchain.pem privkey.pem > bundle.pem
/usr/local/openvpn_as/scripts/sacli --key "cs.ca_bundle" --value_file "bundle.pem" ConfigPut
/usr/local/openvpn_as/scripts/sacli start