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 BaseRequestHandler(tornado.web.RequestHandler): | |
| '''An non-blocking process | |
| Example usage: | |
| class MainHandler(srmlib.BaseRequestHandler): | |
| @tornado.web.asynchronous | |
| def get(self): | |
| self.call_subprocess('sleep 5; cat /var/run/syslog.pid', self.async_callback(self.on_response)) |
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
| #Newbie programmer | |
| def factorial(x): | |
| if x == 0: | |
| return 1 | |
| else: | |
| return x * factorial(x - 1) | |
| print factorial(6) | |
| #First year programmer, studied Pascal |
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 collections import namedtuple | |
| from pymongo import MongoClient | |
| from flask import request | |
| from core.web.site import app | |
| from core.web.site.views_master import * | |
| import json | |
| ''' | |
| $('#companies').dataTable( { | |
| "bProcessing": true, |
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
| This Gist is for my post: http://www.andretw.com/2013/10/What-you-should-know-before-using-DataTables.html |
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 tornado.httpserver | |
| import tornado.ioloop | |
| import tornado.options | |
| import tornado.web | |
| class BaseHandler(tornado.web.RequestHandler): | |
| pass | |
| class HandlerMixin(object): | |
| listeners = [] |
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 threading import Thread | |
| def busy_sleep(n): | |
| while n > 0: | |
| n -= 1 | |
| N = 99999999 | |
| t1 = Thread(target=busy_sleep, args=(N, )) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 authenticated(method): | |
| """Decorate methods with this to require that the user be logged in.""" | |
| @functools.wraps(method) | |
| def wrapper(self, *args, **kwargs): | |
| if not self.current_user: | |
| if self.request.method == "GET": | |
| url = self.get_login_url() | |
| if "?" not in url: | |
| url += "?" + urllib.urlencode(dict(next=self.request.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
| from concurrent.futures import ThreadPoolExecutor | |
| from functools import partial, wraps | |
| import time | |
| import tornado.ioloop | |
| import tornado.web | |
| EXECUTOR = ThreadPoolExecutor(max_workers=4) |
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 concurrent.futures import ThreadPoolExecutor | |
| from functools import partial, wraps | |
| import time | |
| import tornado.ioloop | |
| import tornado.web | |
| EXECUTOR = ThreadPoolExecutor(max_workers=4) |