Skip to content

Instantly share code, notes, and snippets.

View bwarren2's full-sized avatar

Ben Warren bwarren2

  • Education Advisory Board
  • Washington, DC
View GitHub Profile
@bwarren2
bwarren2 / _subscribe_form.html
Created February 24, 2014 19:16
subscribe_form
{% load url from future %}
{% load bootstrap_tags %}
<div class="subscribe-form">
<h2>Purchase a Subscription</h2>
<p class="lead">Provide your payment details to start your subscription today.</p>
{% if error %}
<div class="alert alert-error">{{ error }}</div>
{% endif %}
<form action="{% url 'payments:payments_ajax_subscribe' %}" class="form ajax" data-stripe-key="{{ STRIPE_PUBLIC_KEY }}" data-replace-closest=".subscribe-form" method="POST">
@bwarren2
bwarren2 / api_task.py
Last active August 29, 2015 14:03
api_task
#Task
class ApiCall(BaseTask):
def run(self, mode, **kwargs):
try:
modeDict = {'<mode>': "<url>"}
try:
url = modeDict[mode]
#Error Email
Task app.management.tasks.api_calls.ApiCall with id b670e373-1274-472e-8771-ba2d5d0aa1d0 raised exception:
'SoftTimeLimitExceeded()'
Task was called with args: [] kwargs: {'mode': '<mode>', 'api_context': <app.management.tasks.api_calls.ApiContext object at 0x2bba190>}.
The contents of the full traceback was:
Traceback (most recent call last):
(Pdb) match.entities
<smoke.model.collection.entities.Collection object at 0x7fc502b6dc58>
(Pdb) dir(match.entities)
['__class__', '__contains__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__len__', '__new__', '__pyx_vtable__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'by_cls', 'by_ehandle', 'by_index', 'delete', 'get', 'put']
(Pdb) for a, b in match.entities.by_ehandle.iteritems(): print a, b, b.cls, b.index, b.serial, b.pvs, b.state
2018920 <smoke.model.entity.Entity object at 0x390db48> 8 1640 985 1 <smoke.model.entity.State object at 0x390f1c0>
2057833 <smoke.model.entity.Entity object at 0x390dbd8> 8 1641 1004 1 <smoke.model.entity.State object at 0x390f1e8>
1287786 <smoke.model.entity.Entity object at 0x390dc68> 8 1642 628 1 <smoke.model.entity.State object at 0x390f210>
@bwarren2
bwarren2 / gist:f0b296fff71b78c42488
Created September 24, 2014 17:09
Model_mommy seq errors
#script.py
from heroes.mommy_recipes import make_hero
make_hero(steam_id=1)
# mommy_recipes.py
from model_mommy.recipe import Recipe, seq, foreign_key
from model_mommy import mommy
setwd("~/Downloads")
df.lily = read.csv('lily.csv')
summary(df.lily)
str(df.lily)
colnames(df.lily)
df.lily$cat = ''
df.lily[df.lily$Falling.Asleep.Time==0,]$cat='Put To Sleep'
df.lily[df.lily$Falling.Asleep.Time!=0,]$cat='Self To Sleep'
ben@Watt:~$ python
Python 2.7.5+ (default, Feb 27 2014, 19:37:08)
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> with open('foobar.txt', 'r') as f:
... data = f.read()
...
>>> data
'\n\n# I can totally write C, and just have elected not to here! (Not really.)\n'
>>> with open('foobar.txt', 'w') as f:
### Keybase proof
I hereby claim:
* I am bwarren2 on github.
* I am tenukiben (https://keybase.io/tenukiben) on keybase.
* I have a public key whose fingerprint is 3886 1DBA 8A9A BA47 AF0D D3EA 2CD8 D7E5 84DF 385E
To claim this, I am signing this object:
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
No migrations to apply.
Traceback (most recent call last):
File "proj/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
~ $ python proj/manage.py migrate --fake-initial
/app/.heroku/python/lib/python2.7/site-packages/kombu/utils/__init__.py:407: UserWarning: Module argparse was already imported from /app/.heroku/python/lib/python2.7/argparse.pyc, but /app/.heroku/python/lib/python2.7/site-packages is being added to sys.path
from pkg_resources import iter_entry_points
Operations to perform:
Synchronize unmigrated apps: messages, mptt, rest_framework, tagging, health, bootstrapform, storages, corsheaders, staticfiles, pipeline, django_forms_bootstrap, utils, payments
Apply all migrations: <my apps>, sessions, sites, admin, auth, teams, contenttypes
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...