Skip to content

Instantly share code, notes, and snippets.

@respondcreate
respondcreate / niu_mini--je-20190605.json
Created July 4, 2019 12:28
Niu Mini Keymap (6/05/2019)
{
"author": "respondcreate",
"keyboard": "niu_mini",
"keymap": "niu_mini--je-20190605",
"layers": [
[
"KC_TAB",
"KC_Q",
"KC_W",
"KC_E",
@respondcreate
respondcreate / pyjwt_okta_access_token_local_validate.py
Created February 16, 2019 13:46
PyJWT RS256 Okta Access Token Local Validation Example
"""How to validate Okta Access Tokens Locally with Python"""
import jwt
from jwt.algorithms import RSAAlgorithm
# Key pulled from https://{example}.oktapreview.com/oauth2/{client-id}/v1/keys
key_json = '{"kty":"RSA","alg":"RS256","kid":"your-kid-value-here","use":"sig","e":"AQAB","n":"your-long-key-here"}'
aud = "your-audience-value-here"
token_to_validate = "your-access-token-value-here"
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:*Object*",
"Resource": [
"arn:aws:s3:::{bucket-name}/static/*",
"arn:aws:s3:::{bucket-name}/media/*"
]
@respondcreate
respondcreate / aws-codedeploy-user-data.sh
Last active October 6, 2016 13:32
The user-data needed to launch a CodeDeploy EC2 with docker & docker-compose.
#!/bin/bash
sudo yum -y update
sudo yum install -y ruby
sudo yum install -y aws-cli
sudo yum install -y docker
sudo yum install wget -y
sudo service docker start
sudo usermod -a -G docker ec2-user
sudo pip install docker-compose
cd /home/ec2-user

Keybase proof

I hereby claim:

  • I am respondcreate on github.
  • I am respondcreate (https://keybase.io/respondcreate) on keybase.
  • I have a public key whose fingerprint is BCBA 1B5B D4E9 F90C 555F F06D FBE9 293B 068B AD86

To claim this, I am signing this object:

description "Gunicorn application server running myproject"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
setuid median
setgid www-data
env PATH=/home/user/myproject/ENV/bin
from django.http import HttpResponseForbidden
class RequiredGroupMixin(object):
"""
Ensure only logged in users who belong to a particular group (or groups)
can access this view.
To use this Mixin, just include it as a subclass to your view and add a
new attribute, `restrict_to_groups`, as an iterable of allowed group names.
@respondcreate
respondcreate / lxml_convert_xml_to_obj.py
Last active November 12, 2021 19:06
Using lxml to convert XML into python objects
# You'll need lxml, install it like this:
# $ pip install lxml
# Import objectify from lxml
from lxml import objectify
# Open the XML file in question
f = open('/path/to/xml/file.xml', 'r')
#Ensure the file is ready for parsing
f.seek(0)
@respondcreate
respondcreate / gist:1933871
Created February 28, 2012 17:35
Polymorphic Scrape Method Example
from django.db import models
from django.contrib.contenttypes.models import ContentType
from polymorphic.models import PolymorphicLink
class SomeClass(models.Model):
"""Some attributes"""
def _get_features(self):
ct = ContentType.objects.get(app_label=self._meta.app_label, name=self._meta.verbose_name)
features_set = PolymorphicLink.objects.filter(parent_content_type=ct, parent_object_id=self.pk)