This file contains 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 database import db, Base | |
from sqlalchemy import Column, String, Text | |
from tornado import gen | |
from tornado.httpclient import AsyncHTTPClient | |
class Bookmark(Base): | |
url = Column(Text, nullable=False) | |
data = Column(Text) | |
This file contains 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 tornado.gen | |
import database | |
original_runner_init = tornado.gen.Runner.__init__ | |
original_runner_run = tornado.gen.Runner.run | |
original_runner_handle_exception = tornado.gen.Runner.handle_exception | |
def new_runner_init(self, *args, **kwargs): |
This file contains 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 database | |
class BaseHandler(tornado.web.RequestHandler): | |
def prepare(self): | |
database.scope.set(self) | |
def on_finish(self): | |
database.scope.set(self) |
This file contains 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 sqlalchemy.orm import scoped_session, sessionmaker | |
from sqlalchemy.ext.declarative import declarative_base | |
class Scope(object): | |
def __init__(self): | |
self._current_scope = None | |
def set(self, scope): | |
self._current_scope = scope |
This file contains 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 max_consecutive_sum(nums): | |
max_sum = nums[0] | |
current_sum = 0 | |
for i in nums: | |
current_sum += i | |
if current_sum > max_sum: | |
max_sum = current_sum | |
if current_sum <= 0: | |
current_sum = 0 |
This file contains 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 max_consecutive_sum(nums): | |
max_sum = nums[0] | |
current_sum = 0 | |
for i in nums: | |
current_sum += i | |
if current_sum > max_sum: | |
max_sum = current_sum | |
if current_sum <= 0: | |
current_sum = 0 |
This file contains 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
// | |
// Sign Up Modal ///////////////////////////////////////////////////////// | |
define(function (require) { | |
"use strict"; | |
var Backbone = require('backbone'), | |
$ = require('jquery'), | |
$utils = require('core/utils'), | |
SignUpModal = require('./SignUpModal'); |
This file contains 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
<%= form_for(@product) do |f| %> | |
<%= f.error_messages %> | |
<p> | |
<%= f.label :description %><br /> | |
<%= f.text_field :description %> | |
</p> | |
<p> | |
<%= f.label :value %><br /> | |
<%= f.text_field :value %> | |
</p> |