This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
venv | |
*.pyc | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = "Joshua Kehn <[email protected]>" | |
import sys | |
looking_for = "123456" | |
multiple = 7 | |
for i in xrange(int(looking_for), sys.maxint): | |
s = multiple * i | |
if str(s).endswith(looking_for): | |
print "Found multiple: {0}".format(i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Testing aspen.""" | |
[---] | |
request.redirect("/test.html") | |
[---] | |
You should be redirected to <a href="/test.html">test.html</a>. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fabric.api import local | |
import pip | |
def freeze (): | |
local("pip freeze > requirements.txt") | |
local("git add requirements.txt") | |
local("git commit -v") | |
def upgrade (): | |
for dist in pip.get_installed_distributions(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias pull="git pull"; | |
alias push="git push"; | |
alias prod="git push heroku master:master"; # I have a cleaner function for this that pushes the current branch | |
pull && | |
pull && | |
pull && | |
sleep 10 && | |
pull && | |
push && | |
prod && |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"code":403,"body":"Developer not authorized. The OAuth API is moderated. Did you email [email protected] with a detailed use case?"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Ingredient (models.Model): | |
"""Describes an ingredient for meals. This ingredient contains specific | |
diet and food preference information and can be attached to multiple meals.""" | |
name = models.CharField(max_length=255) | |
franchise = models.ForeignKey(Franchise) | |
diets = models.ManyToManyField(Diet, null=True, blank=True, verbose_name="special diets or food allergies") | |
preferences = models.ManyToManyField(FoodPreference, null=True, blank=True) | |
class Meal (NutritionCapable, PricedModel, DatedModel): | |
"""Basic object representing a meal. NutritionCapable, PricedModel, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import forms | |
from menu.models import Ingredient, Diet, FoodPreference | |
class IngredientForm (forms.ModelForm): | |
class Meta: | |
model = Ingredient | |
exclude = ["franchise"] | |
def __init__ (self, *args, **kwargs): | |
brand = kwargs.pop("brand") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Custom JS macros for creating tags in GTM that populate event information from | |
* element attributes. | |
* | |
* Author: Joshua Kehn <[email protected]> | |
* Copyright: (c) 2014 by Joshua Kehn | |
* License: ISC <http://www.isc.org/downloads/software-support-policy/isc-license/> | |
*/ | |
function () { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def some_view (request): | |
# Could substitute `None` with some other default value | |
key = request.POST.get("key", None) | |
return render(request, "mytemplate.html", {"key": key}) | |
# In mytemplate.html you'll now have `key` available with whatever was submitted via the form. Note | |
# that there is NO validation here, you should probably be using a form to capture the input, | |
# validate it, and return it. https://docs.djangoproject.com/en/dev/ref/forms/api/ |