Skip to content

Instantly share code, notes, and snippets.

@bernardoVale
bernardoVale / drop.sh
Created May 3, 2018 12:14
Drop Postgres DB
# Run this query
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'target_db'
AND pid <> pg_backend_pid();
DROP DATABASE target_db;
@bernardoVale
bernardoVale / cert_tools.sh
Last active April 17, 2018 19:09
Testing Java SSL
java -Djavax.net.ssl.trustStore=frontend_epsKeystore_fugazi.jks -jar java-keystore-test-0.0.1.jar https://ecinventqark1v.wsgc.com:49184/loyalty/v1/loyaltyAccounts?phone=19164754536
EPS: /apps/tomcat/conf/frontend_epsKeystore_fugazi.jks
Loyalty: /apps/tomcat/conf/frontend_keystore.jks
password
ecinvent-qa-rk1v.wsgc.com
@bernardoVale
bernardoVale / besteffort.sh
Created March 16, 2018 15:55
List all Pods with BestEffort
kubectl get pods --all-namespaces -o json | jq -r '.items[] | select(.status.qosClass == "BestEffort") ' | jq -r '.spec.containers[].name'
@bernardoVale
bernardoVale / certificate.sh
Last active January 29, 2018 12:21
Converting certificates
# Download ca from
openssl x509 -in ~/Downloads/COMODORSAAddTrustCA.crt -inform DER -out hostname.crt.pem -outform PE
openssl x509 -inform DER -in comodo.crt -out comodo.pem -text
@bernardoVale
bernardoVale / stress.sh
Created January 28, 2018 18:47
Stress test
wrk -c 20 -t 4 -d 600s https://acob-service-staging.avenuecode.com/api/v1/thirdpartyservices
@bernardoVale
bernardoVale / vim.sh
Created January 26, 2018 12:37
Vim Utils
# Base64
:.!base64
# Decode
:.!base64 -D
# . = line
# % = file
# Enter mode visual, select and :!base64
@bernardoVale
bernardoVale / RECREATE.md
Created January 17, 2018 14:06
Recreate Lost PVC with unexistent PV

State, due to a bug Kubernetes lost the state of a persistent volume. The volume existed in AWS, so I've decided to recover the state.

PVC existed but with state Lost:

kubectl -n acdc-legacy get pvc
NAME                                            STATUS    VOLUME                                     CAPACITY   ACCESSMODES   STORAGECLASS   AGE
acdclegacy-staging-data-acdclegacy-postgres-0   Lost      pvc-dbd2ac08-f32e-11e7-b70d-1212ccc85de2   0                        default        10d
@bernardoVale
bernardoVale / expimp.sh
Created January 7, 2018 00:16
Export/Import Postgres
pg_dump -h 54.162.150.192 -d alpha-quester -U aquser -W > alpha.dmp
psql -h 127.0.0.1 -U aquser -W alpha-quester < alpha.dmp
@bernardoVale
bernardoVale / k8s.sh
Created January 5, 2018 12:52
Kubernetes Sheet
# Copy file from pod to my host
kubectl cp kube-system/nginx-ingress-controller-3224139886-92k85:/etc/nginx/nginx.conf nginx.conf
@bernardoVale
bernardoVale / app.py
Last active November 23, 2017 01:08
Flask mysql start
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://flask:flask@127.0.0.1/flask'
db = SQLAlchemy(app)
class Example(db.Model):
__tablename__ = 'example'