Skip to content

Instantly share code, notes, and snippets.

View jamstooks's full-sized avatar
🐶

Benjamin W Stookey jamstooks

🐶
  • Bellingham, WA
View GitHub Profile
@jamstooks
jamstooks / mixin.py
Created June 9, 2011 21:36
Mixin Class extending Django generic class-based views to provide a persistent custom context. Used mostly for using the request to access an object. Snippet included that uses TemplateWithContextMixin to add the requested org (from /path/to/org) to the t
from django.views.generic.base import TemplateResponseMixin
from django.shortcuts import get_object_or_404
from django.http import Http404
from leaguejam.apps.menus.manage_org import manage_org_menu
from leaguejam.apps.accounts.models import Org
class TemplateWithContextMixin(TemplateResponseMixin):
"""
Class Based view that stores a `custom_context` property that extends
@jamstooks
jamstooks / gist:1067706
Created July 6, 2011 16:40
Orderable List Mixins
from leaguejam.apps.manage.org.views import OrgContextMixin
from leaguejam.apps.manage.org.participants.forms import ParticipantSearchForm
from django.views.generic.list import ListView, MultipleObjectMixin
from django.views.generic.edit import FormMixin
from django.db.models import Q
import re
class FormMixinGET(FormMixin):
Traceback (most recent call last):
File "/usr/sbin/xm", line 8, in <module>
from xen.xm import main
File "/usr/src/xen-3.3.0/dist/install/usr/lib64/python/xen/xm/main.py", line 56, in <module>
File "/usr/src/xen-3.3.0/dist/install/usr/lib64/python/xen/util/acmpolicy.py", line 31, in <module>
File "/usr/src/xen-3.3.0/dist/install/usr/lib64/python/xen/util/xsm/acm/acm.py", line 39, in <module>
File "/usr/src/xen-3.3.0/dist/install/usr/lib64/python/xen/xend/XendOptions.py", line 483, in instance
File "/usr/src/xen-3.3.0/dist/install/usr/lib64/python/xen/xend/XendOptions.py", line 139, in __init__
File "/usr/src/xen-3.3.0/dist/install/usr/lib64/python
@jamstooks
jamstooks / chartbeat.py
Created May 29, 2013 20:50
Just a quick tool I put together to output the number of people on a site using the chartbeat api and the python requests library. Useful for GeekTool and other visualization tools.
#!/usr/bin/env python
"""
A quick tool to output the number of people on a site
using the chartbeat api and the python requests library
Useful for GeekTool and other visualization tools
"""
import requests
@jamstooks
jamstooks / PC Select Docs
Created August 8, 2013 19:52
Here's the spec for that jquery plugin I'm working on. There will also end up being a group of django widgets to go with it, like "CreditSelect" and "DocumentationFieldSelect" that can be restricted to specific CreditSets if necessary.
Parent-child pull-downs
=======================
I need a way to generate a set of pulldowns that can populated based on what's selected in the parent.
Required Functionality
----------------------
- can be initially populated with the existing value
- assumes unique id's at every level (not going to cater to that kinda craziness)

This is a test

Just a test gist...

Heading

@jamstooks
jamstooks / markdown_example.md
Created December 6, 2013 09:04
Markdown test for stylemarkup.com

Markdown!

This is a tests

@jamstooks
jamstooks / signature.py
Created November 10, 2016 19:24
Potential signature generator method for MemberSuite SOAP API
from base64 import b64encode
from hashlib import sha1
import hmac
def hash_signature(url, association_id, secret_access_key, session_id=None):
"""
Process from Membersuite Docs: http://bit.ly/2eSIDxz
"""
@jamstooks
jamstooks / thoughts.md
Last active November 23, 2018 16:34
Thoughts

Random thoughts on code

index.js files get confusing in IDE tabs

In some projects I'll have 7 tabs open and six of them are labeled index.js. This can get super confusing.

So, instead of:

src/containers/UserContainer/index.js
@jamstooks
jamstooks / useRect.js
Last active July 23, 2019 20:07
Hook to get a bounding rect object for a specific, referenced DOM object
import { useEffect, useState } from 'react'
/**
* makes a `rect` object available to a component based on the
* dimensions of DOM object using a reference
*
* Usage:
* const MyComponent = (props) => {
* const _ref = useRef(null)
* const rect = useRect(_ref)