Skip to content

Instantly share code, notes, and snippets.

* what it's like to not be technical in the industry
* what you do in tech that people forget is needed
* the most interesting thing you've worked on recently
* what your day-to-day is like
* must-have gifs for every techie
* horrible code from the past that shows I'm much better now
* the best music for hacking
* mistakes you've made that make you groan
* how you've made it at well-known companies
* self-care in the tech bubble
@MichelleGlauser
MichelleGlauser / gist:997f16f1e29cc004d8ff
Last active August 29, 2015 14:22
Zana Stripe Subscribe Form
{% extends "djstripe/base.html" %}
{% load static djstripe_tags %}
{% block title %}Zana Edge Subscription{% endblock title %}
{% block content %}
<!-- Modal for server update -->
<div class="modal fade" id="in-progress">
<div class="modal-dialog">
<div class="modal-content">
class StripeCouponView(generic.View):
def get(self, request):
stripe.api_key=settings.STRIPE_SECRET_KEY
# coupon = stripe.Coupon.retrieve("ZANAFAMILY")
# print coupon
# log.debug(request.GET)
# # Saves the characters after "=" as coupon_code
# coupon_code = request.GET.get('coupon', '')
if "coupon" in request.GET:
coupon_code = request.GET['coupon']
# models.py
def subscribe(self, plan, quantity=1, trial_days=None,
charge_immediately=True, prorate=djstripe_settings.PRORATION_POLICY, discount_code=None):
cu = self.stripe_customer
"""
Trial_days corresponds to the value specified by the selected plan
for the key trial_period_days.
"""
if ("trial_period_days" in djstripe_settings.PAYMENTS_PLANS[plan]):
@MichelleGlauser
MichelleGlauser / gist:8f40c75e5cd7a199ff55
Created June 5, 2015 19:46
Django StripeCouponView
# Stripe coupons!
class StripeCouponView(generic.View):
def get(self, request):
log.debug(request.GET)
coupon_code = request.GET.get('coupon', '')
api_url = 'https://api.stripe.com/v1/coupons/' + coupon_code
try:
r = requests.get(api_url, auth=(settings.STRIPE_SECRET_KEY, ''))
r.raise_for_status()
@MichelleGlauser
MichelleGlauser / gist:c0225076561f7e5d9946
Created May 9, 2014 00:12
Error after quitting local server
^CTraceback (most recent call last):
File "/Users/michelleglauser/.virtualenvs/venv/bin/envdir", line 8, in <module>
load_entry_point('envdir==0.6.1', 'console_scripts', 'envdir')()
File "/Users/michelleglauser/.virtualenvs/venv/lib/python2.7/site-packages/envdir/__init__.py", line 14, in run
go(runner.run, *args)
File "/Users/michelleglauser/.virtualenvs/venv/lib/python2.7/site-packages/envdir/__main__.py", line 12, in go
caller(args[0], *args[1:])
File "/Users/michelleglauser/.virtualenvs/venv/lib/python2.7/site-packages/envdir/runner.py", line 123, in run
self.terminate()
File "/Users/michelleglauser/.virtualenvs/venv/lib/python2.7/site-packages/envdir/runner.py", line 131, in terminate
if ENVIRONMENT == 'dev':
APP_BASE_LINK = 'http://127.0.0.1:5000'
DEBUG = True
DEBUG_TOOLBAR = True
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'chishenma',
'HOST': 'localhost',
'PORT': '5432',
2014-05-06T01:31:19.612972+00:00 app[web.1]: 2014-05-06 01:31:19 [2] [INFO] Shutting down: Master
2014-05-06T01:31:19.607959+00:00 app[web.1]: 2014-05-06 01:31:19 [2] [INFO] Handling signal: term
2014-05-06T01:31:24.431329+00:00 app[web.1]: 2014-05-06 01:31:24 [2] [INFO] Starting gunicorn 18.0
2014-05-06T01:31:24.432145+00:00 app[web.1]: 2014-05-06 01:31:24 [2] [INFO] Listening at: http://0.0.0.0:12988 (2)
2014-05-06T01:31:24.432246+00:00 app[web.1]: 2014-05-06 01:31:24 [2] [INFO] Using worker: sync
2014-05-06T01:31:24.438350+00:00 app[web.1]: 2014-05-06 01:31:24 [7] [INFO] Booting worker with pid: 7
2014-05-06T01:31:23.549291+00:00 heroku[web.1]: Starting process with command `gunicorn chishenma_project.wsgi`
2014-05-06T01:31:24.686011+00:00 heroku[web.1]: State changed from starting to up
2014-05-06T01:31:26.678788+00:00 heroku[router]: at=info method=GET path=/ host=chishenma.herokuapp.com request_id=42e0c5b7-4bfd-48f9-bd42-aff99dd42c9f fwd="107.6.122.130" dyno=web.1 connect=2ms service=169ms status=500 by
2014-05-06T00:14:54.508614+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=chishenma.herokuapp.com request_id=2a72e262-0620-40ce-953a-e84b0cb2ac59 fwd="107.6.122.130" dyno= connect= service= status=503 bytes=
2014-05-06T00:14:55.934188+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=chishenma.herokuapp.com request_id=0d747351-85df-4774-a50a-eebf8e70c6de fwd="107.6.122.130" dyno= connect= service= status=503 bytes=
2014-05-06T00:21:31.196635+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=chishenma.herokuapp.com request_id=dd3aea10-1782-4005-84a1-9f8473488843 fwd="107.6.122.130" dyno= connect= service= status=503 bytes=
2014-05-06T00:21:32.473284+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=chishenma.herokuapp.com request_id=8d1d5d5d-a1f2-43c1-8165-00a9874e640e fwd="107.6.122.130" dyno= connect= service= status=503 bytes=
2014-05-06T00:27:21.934717+00:
@MichelleGlauser
MichelleGlauser / gist:6151714
Created August 4, 2013 20:02
BookFairy Django web app Procfile
web: python manage.py runserver 0:$PORT collectstatic --noinput; bin/gunicorn_django --workers=4 --bind=0.0.0.0:$PORT proj/prod_settings.py