Skip to content

Instantly share code, notes, and snippets.

View lost-theory's full-sized avatar

Steven Kryskalla lost-theory

View GitHub Profile
@lost-theory
lost-theory / gist:3925738
Created October 21, 2012 04:29
different delimiters in jinja2 + flask
from flask import Flask, render_template_string, request
class CustomFlask(Flask):
jinja_options = Flask.jinja_options.copy()
jinja_options.update(dict(
block_start_string='<%',
block_end_string='%>',
variable_start_string='%%',
variable_end_string='%%',
comment_start_string='<#',
@lost-theory
lost-theory / gist:3928813
Created October 21, 2012 22:48
flask dynamic url_prefix for blueprints
from flask import Flask, Blueprint, request
## blueprint ##################################################################
bp = Blueprint('category_functionality', __name__)
@bp.route('/')
def index(category):
return "this is the index page for %r" % category
@lost-theory
lost-theory / app.py
Created January 12, 2013 23:49
flask: show request time in template
import time
from flask import Flask, request, g, render_template
app = Flask(__name__)
app.config['DEBUG'] = True
@app.before_request
def before_request():
g.request_start_time = time.time()
import os
from flask import Flask, Blueprint, g
api = Blueprint('api', __name__)
class Server(object):
def __init__(self, data):
self.data = data
@lost-theory
lost-theory / gist:3005268
Created June 27, 2012 16:35
consume JSON REST API blueprint inside flask app
from flask import Flask, jsonify, Blueprint, current_app
import json
## REST api ###################################################################
api = Blueprint('api', __name__)
@api.route("/users")
def users():
return jsonify(users=[
@lost-theory
lost-theory / 01_intro.md
Last active January 16, 2021 17:23
FutureStack14 notes

FutureStack 14 notes

Best talks day 1

  • Taming the Modern Datacenter, Mitchell Hashimoto, Hashicorp
    • look at the future of CM systems using Terraform, moving up a level from managing per-machine resources, enabling Infrastructure as Code for the modern distributed data center (mix of IaaS like AWS/DO, PaaS like Heroku, and SaaS for things like DNS and email); I'm a bit skeptical all the complexity of Terraform is significantly better than a minimal layer of glue code to wire up different APIs together.. still interesting though
  • Towards a Data Driven Product, Techniques and Tools at GitHub, JD Maturen, GitHub
    • covered the basics of data science & analytics, gave some insights into how GitHub does it
  • Understanding Developers in a Post Agile Environment, Ward Cunningham (inventor of wiki), New Relic
  • some interesting ideas on how to become a master engineer, "leveraged activities" vs. normal activities,
@lost-theory
lost-theory / gist:3772472
Created September 23, 2012 17:48
upload file with flask test client
import unittest
from app import app
from cStringIO import StringIO
class UploadTest(unittest.TestCase):
def setUp(self):
self.app = app
self.app.config['TESTING'] = True
self.client = self.app.test_client()
@lost-theory
lost-theory / keybase.md
Created March 29, 2020 21:25
keybase.md

Keybase proof

I hereby claim:

  • I am lost-theory on github.
  • I am stevek (https://keybase.io/stevek) on keybase.
  • I have a public key whose fingerprint is D95C DED5 B2FE 16BF 8D7C 2CAF F3AE 0B74 973D 230D

To claim this, I am signing this object:

@lost-theory
lost-theory / gist:3925780
Created October 21, 2012 04:35
pass mustache template into jinja template
from flask import Flask, render_template_string, request
app = Flask(__name__)
app.config['DEBUG'] = True
@app.route("/")
def index():
#of course you would put these into files
jinja_template = """
{# this is a jinja2 comment #}
@lost-theory
lost-theory / cookbookdiff.py
Created September 18, 2012 22:55
chef cookbook diff
#!/usr/bin/env python
'''\
Usage: cookbookdiff COOKBOOK_NAME COOKBOOK_VER LOCAL_PATH [--nocolor]
Diff your LOCAL_PATH against what is on the chef server for a
given cookbook and version.
--nocolor: don't pipe output through 'colordiff' (in case you want to pipe to something else)
Examples:
cookbookdiff percona_toolkit 0.0.4 ~/chef-repo/cookbooks/percona_toolkit