Skip to content

Instantly share code, notes, and snippets.

Avatar
🏳️‍🌈

Daniel van Flymen dvf

🏳️‍🌈
View GitHub Profile
@dvf
dvf / README.md
Created Feb 21, 2016 — forked from stephenash/README.md
Django on ElasticBeanstalk - HTTP to HTTPS redirects
View README.md

I needed a way to have my Django ElasticBeanstalk application automatically redirect HTTP requrests to HTTPS. Rick Christianson wrote a post [1] about how to do this by overwriting the wsgi.conf file with one that was slightly modified to support the HTTP to HTTPS redirect.

Building off the shoulders of giants, I wanted to do the same, but not have to keep a copy of the config file in my local source directory. Christianson even points out in his post that if ElasticBeanstalk ever changes it's template for the wsgi.conf file, those updates would not be overwritten and you wouldn't get their benefits. To get around that problem, I used sed to insert the new lines into the wsgi.conf file.

References

  1. http://rickchristianson.wordpress.com/2013/11/02/updating-wsgi-automatically-in-amazon-aws/
  2. http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-container_commands
View keybase.md

Keybase proof

I hereby claim:

  • I am dvf on github.
  • I am dvf (https://keybase.io/dvf) on keybase.
  • I have a public key ASAQIUnHg-9CdfTLGHPwrnal9t0rVtRrwrR272z-n25APAo

To claim this, I am signing this object:

View keybase.md

Keybase proof

I hereby claim:

  • I am dvf on github.
  • I am dvf (https://keybase.io/dvf) on keybase.
  • I have a public key ASDMxnfzs4Am9pp5c7i38JACvJCMGlWHABqecGuzoGqr3Qo

To claim this, I am signing this object:

@dvf
dvf / blockchain.py
Last active Jun 16, 2019
Blockchain: Step 1
View blockchain.py
class Blockchain(object):
def __init__(self):
self.chain = []
self.current_transactions = []
def new_block(self):
# Creates a new Block and adds it to the chain
pass
def new_transaction(self):
@dvf
dvf / blockchain.py
Last active Jan 28, 2021
Blockchain: Step 3
View blockchain.py
import hashlib
import json
from time import time
class Blockchain(object):
def __init__(self):
self.current_transactions = []
self.chain = []
@dvf
dvf / blockchain.py
Last active Oct 30, 2018
Blockchain: Step 2
View blockchain.py
block = {
'index': 1,
'timestamp': 1506057125.900785,
'transactions': [
{
'sender': "8527147fe1f5426f9dd545de4b27ee00",
'recipient': "a77f5cdfa2934df3954a5c7c7da5df1f",
'amount': 5,
}
],
@dvf
dvf / blockchain.py
Last active Apr 8, 2018
Step 4: Proof of Work
View blockchain.py
import hashlib
import json
from time import time
from uuid import uuid4
class Blockchain(object):
...
@dvf
dvf / blockchain.py
Created Sep 23, 2017
Step 5: Complete Class
View blockchain.py
import hashlib
import json
from textwrap import dedent
from time import time
from uuid import uuid4
class Blockchain(object):
def __init__(self):
self.current_transactions = []
@dvf
dvf / blockchain.py
Last active Jun 7, 2021
Step 6: Setting up Flask
View blockchain.py
import hashlib
import json
from textwrap import dedent
from time import time
from uuid import uuid4
from flask import Flask
class Blockchain(object):
@dvf
dvf / blockchain.py
Last active Jun 24, 2019
Step 7: Transaction Endpoint
View blockchain.py
import hashlib
import json
from textwrap import dedent
from time import time
from uuid import uuid4
from flask import Flask, jsonify, request
...