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
/* | |
Twitter Bootstrap is a nice library, but the way they handle markup for styles and plugins is a bit invasive at | |
times. Since Bootstrap is built with Less CSS anyway, it makes sense to take advantage of Less to cleanup the | |
markup. | |
This is an attempt at cleaning up the collapsible accordion example. If you don't like the HTML5 tags, you can | |
replace them with divs with classes (make the appropriate changes in the less). | |
One quirk that I know of: if you use the "in" class to indicate a default open article, the first accordion | |
click will not transition smoothly. I haven't figured out why this is happening, but generally with the |
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
<GT> :: = '>' | |
<capchar> ::= 'A' | 'B' | .... | 'Z' | |
<lowerchar> ::= 'a' | 'b' | .... | 'z' | |
<punc> ::= '.' | ',' | .... | |
<WS> ::= ' ' | <TAB> | |
<TO> ::= 'TO:' | |
<DOT> ::= '.' | |
<LP> ::= '(' | |
<RP> ::= ')' | |
<intext> ::= 'INT' | 'EXT' | 'INT/EXT' |
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
"""REST principles state that we should version at the resource level. Both the version and the content-type of a | |
resource should be specified in the Accept header. But many developers prefer an approach which contains API | |
versions in the URL. | |
The approach in this gist finds a happy medium. Resource level versioning is provided, with resources being | |
specified for both version and content-type. Convenience URLs for API version levels are also configured, with each | |
API version being a specific set of versioned resources. | |
vendor-specified content types are configured in the form of vnd.namespace.Resource+mimetype. Routes for each of | |
these are configured as well as generic routes for the appropriate content type with the resource version that is |
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 parse_accept_header(accept): | |
"""Parse the Accept header *accept*, returning a list with pairs of | |
(media_type, q_value), ordered by q values. | |
""" | |
result = [] | |
for media_range in accept.split(","): | |
parts = media_range.split(";") | |
media_type = parts.pop(0) | |
media_params = [] | |
q = 1.0 |
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 pyramid.security import ALL_PERMISSIONS | |
from pyramid.security import Allow | |
from pyramid.security import Everyone | |
ADMINS = [ __some__list__of__admins__ ] | |
def groupfinder(userid, request): | |
"""groupfinder should be the callback to your authentication policy. | |
""" | |
if userid in ADMINS: | |
return ['g:admins'] |
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 pyramid.view import view_config | |
from pyramid.security import remember | |
from pyramid.security import authenticated_userid | |
from pyramid_persona.views import verify_login | |
USE_WHITELIST = False | |
WHITELIST_REJECT_MESSAGE = 'Sorry, you are not authorized to access this site.' | |
WHITELIST_REJECT_REDIRECT = '/' | |
USE_BLACKLIST = False | |
BLACKLIST_REJECT_MESSAGE = 'Sorry, you are not authorized to access this site.' |
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 pyramid.security import ALL_PERMISSIONS | |
from pyramid.security import DENY_ALL | |
from pyramid.security import Allow | |
from pyramid.security import Everyone | |
from sqlalchemy import Column, Integer, Text, Unicode | |
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy.orm import scoped_session, sessionmaker, synonym | |
from zope.sqlalchemy import ZopeTransactionExtension | |
import cryptacular.bcrypt |
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
import logging | |
import time | |
import urlparse | |
from birdy.twitter import AppClient | |
from birdy.twitter import TwitterRateLimitError, TwitterClientError | |
from delorean import parse, epoch | |
""" | |
Utilization: | |
searcher = TwitterSearcher( | |
TWITTER_CONSUMER_KEY, |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<meta name="description" content=""> | |
<meta name="author" content=""> | |
<link rel="shortcut icon" href="../../assets/ico/favicon.ico"> | |
<title>Starter Template for Bootstrap</title> |
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
""" | |
I find the Elasticsearch Python client a bit quirky to work with. A lot of this | |
has to do with the odd way that Elasticsearch documents and results are | |
organized (e.g. ['hits']['hits'] WTF?). The weird organization is exemplified | |
well in the need for the client to expose both `get` and `get_source` methods. | |
Also, there is a pretty bad lack of consistency: ['hits']['hits'] vs. ['docs'], | |
_version (with _) vs. found (without _), etc. | |
This is my crude attempt to make the client a bit more usable. Currently | |
implements `search`, `get`, and `mget`. `get_source` maps to `get` because there |
OlderNewer