Skip to content

Instantly share code, notes, and snippets.

View emilyhorsman's full-sized avatar

Emily Horsman emilyhorsman

  • San Francisco
View GitHub Profile
from .hue import Hue
(60, yellow)
(30.0, red-yellow)
(15.0, red-red-yellow)
(7.5, red-red-red-yellow)
(3.75, red-red-red-red-yellow)
(11.25, yellow-red-red-red-yellow)
(22.5, yellow-red-red-yellow)
(18.75, red-yellow-red-red-yellow)
(26.25, yellow-yellow-red-red-yellow)
(45.0, yellow-red-yellow)
class Hue(object):
"""Maintains an angle representing a Hue on a wheel, typically apart of
an HSL representation of a color.
See https://commons.wikimedia.org/wiki/File:Hsl-hsv_models.svg
:param angle: An angle on the hue wheel. red = 0/360, cyan = 180.
:param percentage: A percentage instead of angle.
:param hex: A hexadecimal value representing angle. 0xFF = 0/360 deg.
:param name: A named hue value, e.g. 'red-yellow'
from django.conf import settings
import requests
def check_recaptcha(request):
payload = {
'secret': settings.RECAPTCHA_SECRET_KEY,
'response': request.POST.get('g-recaptcha-response')
}
res = requests.post("https://www.google.com/recaptcha/api/siteverify", data=payload)
res = res.json()
from django.conf import settings
from django.core.exceptions import ValidationError
from django.forms.widgets import Widget
from django.forms.fields import Field
import requests
class ReCAPTCHAWidget(Widget):
def render(self, name, value, attrs=None):
return """<script src="https://www.google.com/recaptcha/api.js" async defer></script><div class="g-recaptcha" data-sitekey="{}"></div>""".format(settings.RECAPTCHA_SITE_KEY)
from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
from django.contrib.contenttypes.models import ContentType
from django.core.urlresolvers import reverse
from django.db import models
from django.conf import settings
from django.utils import timezone
from django.utils.text import slugify
from taggit.managers import TaggableManager
class Vouch(models.Model):

Django Weekend Learning

You can override the runserver command (or other management commands and make your own. Django 1.8 doesn't use optparse anymore but I rather like it's parser. This is a quick extension of the runserver command to set an env variable which will disable reCAPTCHA fields.

someapp/profile/management/commands/runserver.py:

from django.contrib.staticfiles.management.commands import runserver
import os
from allauth.account.decorators import verified_email_required
class VerifiedEmailRequiredMixin(object):
@classmethod
def as_view(self, **init_kwargs):
view = super(VerifiedEmailRequiredMixin, self).as_view(**init_kwargs)
return verified_email_required(view)

Keybase proof

I hereby claim:

  • I am emilyhorsman on github.
  • I am emilyhorsman (https://keybase.io/emilyhorsman) on keybase.
  • I have a public key whose fingerprint is 2076 6281 1008 4ED7 F8CA AF1B CF75 1D94 807A A4E1

To claim this, I am signing this object:

Re: http://dancerscode.com/blog/why-the-open-code-of-conduct-isnt-for-me/

They, like all forms of political correctness, center around people being offended, sometimes about things like technical ability which can and should be spoken about frankly in any open source project.

Right, so there’s behaviour such as not accepting a PR and saying it didn’t meet review, or there’s telling a newbie that they shouldn’t write code because they’re a woman/trans/person of colour/etc. There’s closing a PR and there’s closing a PR with a joke containing something about a kitchen and a sandwich that we’ve all heard hundreds of times prior attached to it.

>Judging and punishing the behavior of those who speak based on the sensibilities of those who listen is a standard which is inherently unfair to the speaker. This precipitates an environment where the exchange of ideas between people who differ is impossible if either of them thinks that the other may find the topic offensive. This carries with it the danger of stiflin