Skip to content

Instantly share code, notes, and snippets.

import tornado.ioloop
import tornado.web
import tornado.gen
import tornado.httpclient
class GenAsyncHandler(tornado.web.RequestHandler):
@tornado.web.asynchronous
@tornado.gen.engine
def get(self):
# Copyright (c) 2010, Philip Plante of EndlessPaths.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
@codeboy
codeboy / code_organization.js
Last active August 29, 2015 14:15
Javascrip + jQuery - code organization template
BaseApp = function(){
this.params = {
'fdfdf' : 'dsad'
};
this.init = function (params) {
var params = $.extend({}, this.params, params);
var a = this;
a.$content = $('#content');
@codeboy
codeboy / icl_visitors.html
Last active August 30, 2015 14:41
django middleware for counting visitors
<div class="hidden-xs hidden-sm panel panel-default">
<div class="panel-heading">
<h5 align="center">Сейчас на сайте</h5>
</div>
<div class="list-group">
<li class="list-group-item">пользователей: {{ users_count|add:u_count }} ({{ users_count }})</li>
<li class="list-group-item">гостей: {{ anons_count|add:a_count }} ({{ anons_count }})</li>
</div>
</div>
@codeboy
codeboy / BaseAsyncHandler.py
Last active August 30, 2015 14:51
Example Python3 Tornado + asyncio + peewee_async + aiomcache (this is for Hearthstone card parser)
import asyncio
import tornado.ioloop
import tornado.web
import tornado.gen
from tornado.httpclient import AsyncHTTPClient
class AsyncRequestHandler(tornado.web.RequestHandler):
"""
https://github.com/rudyryk/python-samples/blob/master/hello_tornado/hello_asyncio.py
# -*- coding: utf-8 -*-
import os, sys, locale
import site, os
locale.setlocale(locale.LC_TIME,'ru_RU.utf8')
#projects_root = '/home/codeboy/xxx/svn2/'
#
#if projects_root not in sys.path:
@codeboy
codeboy / Base.js
Created August 8, 2012 16:01
ExtJs template
// КОНТРОЛЛЕР
Ext.define('C300.controller.Base', {
extend: 'Ext.app.Controller',
stores:[
'C300.store.streetStore'
],
views: [
@codeboy
codeboy / sms_sender.py
Last active December 19, 2015 19:18
send sms via smsaero.ru
###
# Sending sms via smsaero.ru gate
###
import requests
import time
import hashlib
def sms_sender(
number='79825552211',
@codeboy
codeboy / tree.md
Created July 16, 2013 13:32 — forked from hrldcpr/tree.md

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

Python Number Conversion Chart

From To Expression