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
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
{% 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
#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
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
//The class we need | |
class Transaction { | |
String name | |
int itemCount | |
double cost | |
Date purchaseDate | |
} | |
//our conversion closures | |
def stringToDouble = { |
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 org.junit.Test | |
import static org.junit.Assert.* | |
import org.junit.Before | |
class MapBackedBeanTest { | |
private MapBackedBean mbb | |
@Before |
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 CSVBeanBuilder { | |
public static final Closure STRING_TO_DOUBLE = { token ->return Double.parseDouble(token)} | |
public static final Closure STRING_TO_INT = { token ->return Integer.parseInt(token)} | |
public static final Closure STRING_TO_DATE = { token -> return new Date(java.sql.Date.valueOf(token).time)} | |
def static loadAs(Class clazz, String csv, conversions){ | |
def results = [] | |
def headers = [:] | |
csv.eachLine { line, lineNumber -> |
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 MapBackedBean implements GroovyInterceptable { | |
private Map map = [:] | |
def invokeMethod(String name, args){ | |
if (name == "putAt"){ | |
map[args[0]] = args[1] | |
} else if (name == "getAt"){ | |
return map[args[0]] | |
} else if (args.size() > 1 || name.length() <= 3){ |
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
<div id="content"> | |
{% block alerts %} | |
{% try %} | |
{% if alerts is not None %} | |
{% for alert in alerts %} | |
<div class="{{alert.get('level', 'alert') }}"> | |
{{ alert.get('content') }} | |
</div> | |
{% end %} | |
{% end %} |