Skip to content

Instantly share code, notes, and snippets.

Forked from fjania/gist:6660a531edbe9051a0a8
Last active August 29, 2015 14:22
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
import hashlib
import time
def ramen(request):
ramen_js = '';
if not request.user.is_anonymous():
email =
user_id =
name = "{} {}".format(request.user.first_name, request.user.last_name)
timestamp = int(time.time())
secret_key = "SECRET_KEY_GOES_HERE"
auth_input = "{}:{}:{}:{}:{}".format(
auth_hash = hashlib.sha256(auth_input).hexdigest()
ramen_js = '''
<!-- This can go anywhere before the ramen.js tag -->
window.ramenSettings = {{
organization_id: "555cc17077656204242f0000",
user: {{
name: "{name}",
email: "{email}",
id: "{id}",
timestamp: {timestamp},
auth_hash: "{auth_hash}"
<!-- This goes before the </body> tag -->
<script src="" async>
name = name,
id = user_id,
email = email,
timestamp = timestamp,
auth_hash = auth_hash,
return { 'ramen_js': ramen_js }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment