Skip to content

Instantly share code, notes, and snippets.

View dvf's full-sized avatar

Daniel van Flymen dvf

View GitHub Profile
@dvf
dvf / README.md
Created February 21, 2016 09:57 — forked from stephenash/README.md
Django on ElasticBeanstalk - HTTP to HTTPS redirects

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

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:

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
Created September 23, 2017 20:31
Step 9: Consensus (Retrieve Chain)
@app.route('/chain', methods=['GET'])
def full_chain():
response = {
'chain': blockchain.chain,
'length': len(blockchain.chain),
}
return jsonify(response), 200
@dvf
dvf / blockchain.py
Last active February 22, 2018 21:10
Creating a simple Blockchain in Python
class Blockchain(object):
def __init__(self):
self.current_transactions = []
self.chain = []
def new_block(self):
# Creates a new Block in the Blockchain
pass
def new_transaction(self):
@dvf
dvf / blockchain.py
Last active April 8, 2018 00:23
Step 4: Proof of Work
import hashlib
import json
from time import time
from uuid import uuid4
class Blockchain(object):
...
@dvf
dvf / blockchain.py
Created September 23, 2017 18:30
Step 5: Complete Class
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
Created September 23, 2017 19:03
Step 2.1: Creating a Transaction
class Blockchain(object):
...
def new_transaction(self, sender, recipient, amount):
"""
Creates a new transaction to go into the next mined Block
:param sender: <str> Address of the Sender
:param recipient: <str> Address of the Recipient
:param amount: <int> Amount
@dvf
dvf / MD5.js
Created May 19, 2019 20:20
MD5 Algorithm for Google Sheets
function MD5 (input) {
var digest = Utilities.computeDigest(Utilities.DigestAlgorithm.MD5, input);
var output = "";
for (i = 0; i < digest.length; i++) {
var h = digest[i];
if (h < 0) { h += 256; }
if (h.toString(16).length == 1) { output += '0'; }
output += h.toString(16);
}
return output;
@dvf
dvf / blockchain.py
Last active June 16, 2019 07:54
Blockchain: Step 1
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):