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 mappings = [ | |
[csvProperty: "item name", classProperty: "name"], | |
[csvProperty: "cost in $", classProperty: "cost", conversion: CSVBeanBuilder.STRING_TO_DOUBLE], | |
[csvProperty: "count", classProperty: "itemCount", conversion: CSVBeanBuilder.STRING_TO_INT], | |
[csvProperty: "date", classProperty: "purchaseDate", conversion: CSVBeanBuilder.STRING_TO_DATE], | |
] | |
CSVBeanBuilder.loadAs(MapBackedBean.class, csvText, mappings).each { | |
transaction -> | |
assert(transaction.name == transaction.getName() && transaction.getName() == transaction["name"] ) |
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
#add this to your base handler class | |
def write_error(self, status_code, **kwargs): | |
error_trace = None | |
if self.settings.get("debug") and "exc_info" in kwargs: | |
import traceback | |
error_trace= "" | |
for line in traceback.format_exception(*kwargs["exc_info"]): | |
error_trace += line | |
self.render("base_error.html", status_code=status_code, error_trace=error_trace) |
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
{% extends "base.html" %} | |
{% block page_title %} - Buy Goods {% end %} | |
{% block head %} <script type="text/javascript" src="https://stage.wepay.com/js/iframe.wepay.js"></script> {% end %} | |
{% block page_content %} | |
<div id="checkout"></div> | |
{% end %} | |
{% block js %} | |
WePay.iframe_checkout("checkout", "{{checkout["checkout_uri"]}}"); |
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 Backend(object): | |
def __init__(self): | |
engine = create_engine("mysql://{0}:{1}@{2}/{3}".format(options.mysql_user, options.mysql_pass, options.mysql_host, options.mysql_db) | |
, pool_size = options.mysql_poolsize | |
, pool_recycle = 3600 | |
, echo=options.debug | |
, echo_pool=options.debug) | |
self._session = sessionmaker(bind=engine) | |
@classmethod |
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
self.webView.scrollView.decelerationRate = 0.994f; |
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
Traceback (most recent call last): | |
File "/Users/DLC/.virtualenvs/b/lib/python2.7/site-packages/tornado/web.py", line 1021, in _stack_context_handle_exception | |
raise_exc_info((type, value, traceback)) | |
File "/Users/DLC/.virtualenvs/b/lib/python2.7/site-packages/tornado/stack_context.py", line 258, in _nested | |
yield vars | |
File "/Users/DLC/.virtualenvs/b/lib/python2.7/site-packages/tornado/stack_context.py", line 228, in wrapped | |
callback(*args, **kwargs) | |
File "/Users/DLC/.virtualenvs/b/lib/python2.7/site-packages/tornado/gen.py", line 382, in inner | |
self.set_result(key, result) | |
File "/Users/DLC/.virtualenvs/b/lib/python2.7/site-packages/tornado/gen.py", line 315, in set_result |
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
static inline NSRegularExpression * TagRegularExpression() { | |
static NSRegularExpression *_tagRegularExpression = nil; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
_tagRegularExpression = [[NSRegularExpression alloc] initWithPattern:@"\\#[\\w]+" | |
options:NSRegularExpressionCaseInsensitive | |
error:nil]; | |
}); | |
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 FacebookGraphLoginHandler(BaseHandler, tornado.auth.FacebookGraphMixin): | |
@tornado.web.asynchronous | |
def get(self): | |
my_url = (self.request.protocol + "://" + self.request.host +"/login/facebook?next="+tornado.escape.url_escape(self.get_argument("next", "/"))) | |
if self.get_argument("code", False): | |
self.get_authenticated_user(redirect_uri=my_url,client_id=self.settings["facebook_api_key"],client_secret=self.settings["facebook_secret"],code=self.get_argument("code"),callback=self._on_auth,extra_fields=['email']) | |
return | |
self.authorize_redirect(redirect_uri=my_url,client_id=self.settings["facebook_api_key"],extra_params={"scope": "read_stream,email,offline_access"}) | |
def _on_auth(self, user): |
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 Backend(object): | |
"""Allows access to backend and removes logic from handlers""" | |
def __init__(self): | |
"""Inititalize with the variables you need""" | |
self.__users_data = None | |
self.db = Connection( | |
options.db_host, | |
options.db, | |
user=options.db_user, |
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
# -*- coding: utf-8 -*- | |
from markdown import Extension | |
from markdown.util import etree | |
from markdown.inlinepatterns import Pattern | |
SOURCES = { | |
"youtube": { | |
"re": r'youtube\.com/watch\?\S*v=(?P<youtube>[A-Za-z0-9_&=-]+)', | |
"embed": "//www.youtube.com/embed/%s" | |
}, |