Skip to content

Instantly share code, notes, and snippets.

@pilgrim2go
pilgrim2go / fix.sh
Created June 12, 2018 04:20
[SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version
```
I was getting this error too. I tried many suggestions, dint work. This one worked..
check which python & its ssl version
python -c "import ssl; print(ssl.OPENSSL_VERSION)"
OpenSSL 1.0.2f 28 Jan 2016
python3 -c "import ssl; print (ssl.OPENSSL_VERSION)"
OpenSSL 0.9.8zh 14 Jan 2016
@pilgrim2go
pilgrim2go / gist:f3158b76a7970cc73811e1688336d5a1
Created December 20, 2017 03:00 — forked from giannisp/gist:ebaca117ac9e44231421f04e7796d5ca
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
brew unlink postgresql
brew install postgresql@9.6
brew unlink postgresql@9.6
brew link postgresql
@pilgrim2go
pilgrim2go / Find unused AWS security groups
Created December 8, 2017 04:52
Find unused AWS security groups
From: https://stackoverflow.com/questions/24685508/how-to-find-unused-amazon-ec2-security-groups
Note: this only considers security use in EC2, not other services like RDS. You'll need to do more work to include security groups used outside EC2. The good thing is you can't easily (might not even be possible) to delete active security groups if you miss one associated w/another service.
Using the newer AWS CLI tool, I found an easy way to get what I need:
First, get a list of all security groups
aws ec2 describe-security-groups --query 'SecurityGroups[*].GroupId' --output text | tr '\t' '\n'
Then get all security groups tied to an instance, then piped to sort then uniq:
@pilgrim2go
pilgrim2go / cli.md
Created December 6, 2017 05:18 — forked from phrawzty/2serv.py
simple http server to dump request headers
$ curl -s -H "X-Something: yeah" localhost:8000 > /dev/null
$ python serv.py
ERROR:root:User-Agent: curl/7.37.1
Host: localhost:8000
Accept: */*
X-Something: yeah
@pilgrim2go
pilgrim2go / README.md
Created November 22, 2017 09:27 — forked from ifnull/README.md
Using TOR as a proxy for Python on OSX
sudo apt-get install tor
# check tor service running on port 9050 (ss -aln | grep 9050)
# change ip after every 10 sec
edit vi /etc/tor/torrc and add MaxCircuitDirtiness 10
# use tor proxy in python request
install requests==2.10.0 (pip install requests==2.10.0) (currently 2.11 giving error)
@pilgrim2go
pilgrim2go / README.md
Created October 13, 2017 01:28 — forked from sapessi/README.md
Continuous deployment of React websites to Amazon S3

Continuous deployment of React websites to Amazon S3

This sample includes a continuous deployment pipiline for websites built with React. We use AWS CodePipeline, CodeBuild, and SAM to deploy the application. To deploy the application to S3 using SAM we use a custom CloudFormation resource.

Files included

  • buildspec.yml: YAML configuration for CodeBuild, this file should be in the root of your code repository
  • configure.js: Script executed in the build step to generate a config.json file for the application, this is used to include values exported by other CloudFormation stacks (separate services of the same application).
  • index.js: Custom CloudFormation resource that publishes the website to an S3 bucket. As you can see from the buildspec and SAM template, this function is located in a s3-deployment-custom-resource sub-folder of the repo
  • app-sam.yaml: Serverless Application model YAML file. This configures the S3 bucket and the cu
@pilgrim2go
pilgrim2go / postgres-cheatsheet.md
Created September 20, 2017 06:03 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -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)
@pilgrim2go
pilgrim2go / psql-with-gzip-cheatsheet.sh
Created September 19, 2017 07:13 — forked from brock/psql-with-gzip-cheatsheet.sh
Exporting and Importing Postgres Databases using gzip
# This is just a cheat sheet:
# On production
sudo -u postgres pg_dump database | gzip -9 > database.sql.gz
# On local
scp -C production:~/database.sql.gz
dropdb database && createdb database
gunzip < database.sql.gz | psql database
@pilgrim2go
pilgrim2go / checkDockerDisks.sh
Created August 15, 2017 08:34 — forked from robsonke/checkDockerDisks.sh
This Bash script will loop through all running docker containers on a host and list the disk usage per mount. In case it's breaching the 65%, it will email you.
#!/bin/bash
# get all running docker container names
containers=$(sudo docker ps | awk '{if(NR>1) print $NF}')
host=$(hostname)
# loop through all containers
for container in $containers
do
echo "Container: $container"