Skip to content

Instantly share code, notes, and snippets.

View eezis's full-sized avatar

Ernest Ezis eezis

  • Boulder, CO
View GitHub Profile
eezis / Django EC2 Bad Request (400)
Last active June 28, 2023 16:23
Resolving Bad Request (400) when using Django on an EC2 instance DEBUG
This gist pertains to a Bad Request(400) error when trying to access an EC2 instance running django . . .
I set up an EC2 server, installed django, started runserver and tested. The result was
Bad Request (400)
When using Django 1.5 and higher, if you specify DEBUG=False in the file, you must also specify ALLOWED_HOSTS
or you will recieve a "Bad Request (400)" error message when attempting to retrieve a page.
On an Amazone EC2 instance, if you are ***testing*** with the public DNS, then you should include the public DNS as one of the allowed hosts.
eezis /
Last active November 13, 2022 04:21
Get your Phemex Positions and Balance using CCXT -- in jupyter notebook
# -*- coding: utf-8 -*-
import os
import sys
from pprint import pprint
import ccxt
import pandas as pd
eezis /
Created November 6, 2022 17:27
Django EC2 ELB Nginx PageSpeed upstream sent more data than specified in "Content-Length" header

While upgrading EC2 servers behind an AWS Elastic Load Balancer (ELB) I noticed that the nginx error log was reporting that my health-check was getting molested. Here is the simple curl test showing the 200 result. The error message, then the solution follow.

$ curl -I localhost/ELB-health-check

HTTP/1.1 200 OK
Server: nginx
Date: Sun, 06 Nov 2022 16:59:46 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 105
eezis /
Created October 6, 2022 19:56
Django Migrations TypeError: attribute name must be string, not 'bytes'

If you are updating and older Django project and getting an error in this form:

TypeError: attribute name must be string, not 'bytes'

It's likely that you have existing migrations in your code base that have legacy byte strings. I found them in two places. In the related_name as shown below

('article', models.ForeignKey(related_name=b'author', to='core.Article', on_delete=models.CASCADE, null=True)),
eezis /
Created April 19, 2016 21:03
Horizontal Radio Buttons For Boolean Values Using Crispy Forms with Django
Quick guide to getting inlineradio buttons when using boolean values with Crispy Forms.
1. create chocies
(True, u'Yes'),
(False, u'No'),
2. update model to point at the choices
eezis / firebase.js
Created August 8, 2019 21:51
quasar firebase & vuefire boot file
import { firestorePlugin } from 'vuefire'
import { firebase } from '@firebase/app'
import 'firebase/firestore'
import 'firebase/auth'
import firebaseConfig from '../../firebaseConfig'
let firebaseApp = firebase.initializeApp(firebaseConfig)
let firebaseAuth = firebaseApp.auth()
const db = firebaseApp.firestore()
eezis / gist:eddd935a942f24936dcf41edf780be9b
Created October 21, 2016 19:54
Spread across cores using the multiprocessing library
import sys
import subprocess
import multiprocessing
# use htop to see the utilization rates spread across cores
# use locust --help to see all the options
# the cmd launches 500 concurrent users on each core, hatch 5 per second, issue 10k requests then stops
# logs to results.txt, prints the summary in the terminal
eezis / gist:1ae5050a524d7c14229db2658143ad4a
Last active January 5, 2021 13:23
Get Ethereum and ERC20 positions from an Ethereum address
see my comment below the gist
import re
import os
from requests_html import HTMLSession
eezis / gist:3a198b9f65d1d3171c8cd20b30562d36
Created April 10, 2020 18:26
If you need to find the location of a poetry virtualenv for a project . . .
# inside an active poetry shell . . .
$ which python

Keybase proof

I hereby claim:

  • I am eezis on github.
  • I am ernestezis ( on keybase.
  • I have a public key ASCKvfwAKTfOPX-0ro-E-kpjgG6zedSp2JUGk-4zSCRcuwo

To claim this, I am signing this object: