Skip to content

Instantly share code, notes, and snippets.

@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 / utils.py
Last active July 29, 2021 01:36
Remove HTML tags + entities from string in Python +Django
import re
from django.utils.html import strip_tags
def parse_text(text, patterns=None):
"""
delete all HTML tags and entities
:param text (str): given text
:param patterns (dict): patterns for re.sub
:return str: final text
@codeboy
codeboy / template_iterator.html
Last active February 2, 2021 15:38
Django templates - iterate over nested dictionary
Sample code:
main template: assuming 'all_root_elems' is list of one or more root of tree
<ul>
{%for node in all_root_elems %}
{%include "tree_view_template.html" %}
{%endfor%}
</ul>
@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 / gist:923f74b72abda9502f42
Created February 1, 2015 15:50
A very simple example of python code to us with python-libtorrent
'''
You should try libtorrent (rasterbar). http://libtorrent.org
If you want to write your client in python, on linux, install it with:
sudo apt-get install python-libtorrent
A very simple example of python code to use it to download a torrent:
'''
import libtorrent as lt
@codeboy
codeboy / CV_Resume.markdown
Last active January 27, 2024 19:25
Maxim Vavilov - Full-stack Python developer - CV (resume)

Меня зовут Вавилов Максим.

Я программист на Python/Django и Javascript.

Skype - codeboy.ru

Опыт более 10 лет работы в разработке интернет проектов. Принял участие в создании и развитии десятках различных проектов. От сложных, до очень сложных. Умею работать как в большой команде, так и один. Могу разрабатывать проекты, как с нулевой стадии, так и переделывать уже действующие. Способен спасти даже самый пропащий проект.

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 / test.py
Last active December 19, 2015 21:48
def get_context(self, request):
context = self.context
query = '''
SELECT pp.*, cc.*, au.*, row_to_json(rf.*) as recv_fund, row_to_json(ci.*) as invoice FROM payments_payment pp
LEFT JOIN customers_customer cc ON cc.id=pp.customer_id
LEFT JOIN auth_user au ON au.id=cc.user_id
LEFT JOIN payments_receivedfund rf ON pp.op_type=0 AND rf.id=pp.target
LEFT JOIN customers_customerinvoice ci ON pp.op_type=2 AND ci.id=pp.target
'''
q_payments, q_rows = db_aliases_query_dict(query, 'hosting')

Python Number Conversion Chart

From To Expression