Skip to content

Instantly share code, notes, and snippets.

View diyan's full-sized avatar

Oleksii Diian diyan

View GitHub Profile
@diyan
diyan / csv_to_vcard.py
Created September 10, 2012 11:20
Converts exported CSV-file from http://www.easyprograms.narod.ru/PhoneBook/Main.html program into vCard format
# -*- coding: utf-8 -*-
import csv
import os
import codecs
import unicodedata
import vobject
from vobject.vcard import Name, Address
input_path = u'D:/projects/csv_to_vcard/phonebook_exported_20120910.csv'
output_dir = u'D:/projects/csv_to_vcard/output_20120910/'
@diyan
diyan / fix_docker_ps.md
Last active November 8, 2015 10:28
Fix. Default output from 'docker ps' command is too wide

Fix. Default output from 'docker ps' command is too wide

$ docker ps -a
CONTAINER ID        IMAGE                    COMMAND                CREATED             STATUS                     PORTS               NAMES
e33e91281698        choam_nagios4            "/usr/bin/supervisor   12 days ago         Exited (0) 12 days ago                         choam_nagios4
@diyan
diyan / choosing_http_mock_library.md
Created December 18, 2012 12:04
Choosing HTTP mock library
@diyan
diyan / patch_python_couchbase_for_read_data_stored_by_dotnet_client.py
Created December 19, 2012 14:43
Monkey patch Couchbase Python client in order to work with data stored by .NET couchbase client.
# Monkey patch Couchbase Python client in order to work with data stored by .NET couchbase client.
# http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-views-datastore-fields.html
# Both Python and .NET couchbase clients using fields in document metadata
# for storing type information which does not compatible with each other.
def get_patched_couchbase():
from couchbase.constants import MemcachedConstants
import struct as original_struct
unpack_original = original_struct.unpack

Tornado (Web framework)

TornadIO2 = Tornado + Socket.IO / Хабрахабр - http://habrahabr.ru/post/133350/

TornadIO2 — TornadIO2 0.1 documentation - http://tornadio2.readthedocs.org/en/latest/

Realtime Web №2 - TornadIO | Кушаем у мистера Джо - http://mrjoes.tumblr.com/post/2963182191/tornadio

Использование Nginx+Tornado для приложений на Django / Мастерская интернет-разработчика - http://adw0rd.com/2009/11/15/nginx-tornado-django/

from jinja2 import evalcontextfilter, escape
from markdown import Markdown
from bottle import app, route, run, redirect, static_file
from bottle import jinja2_template as template
"""
import bottle
from bottle_debugtoolbar import DebugToolbarPlugin
config = {
'DEBUG_TB_ENABLED': True,
@diyan
diyan / proxied_circushttpd.py
Created May 23, 2013 16:57
Helper script for host circus-web app behind Nginx reverse proxy with prefixed path.
class ReverseProxied(object):
'''Wrap the application in this middleware and configure the
front-end server to add these headers, to let you quietly bind
this to a URL other than / and to an HTTP scheme that is
different than what is used locally.
In nginx:
location /myprefix {
proxy_pass http://192.168.0.1:5001;
proxy_set_header Host $host;
@diyan
diyan / test_parametrized_samples.py
Last active December 19, 2015 23:59
Samples how-to use parametrized tests in pyt.test framework.
"""
3 samples how-to use parametrized tests in pyt.test framework:
1. Parametrized fixture with simple string types will generate friendly test name.
2. Parametrized fixture with complex type require you implement __hash__ and __str__ methods. But you will not see friendly test names.
3. The only way to see friendly test names with complex types is to implement pytest_generate_tests hook.
"""
from pytest import fixture
@diyan
diyan / post-update.sh
Last active December 20, 2015 09:09
Git. Hooks. Post update hook to deploy site from repo host to the remote host or web-farm
NEW
#!/bin/bash
set -e
declare -r SSH_USER=www-data
declare -r SSH_KEY=~/.ssh/www-data.pem
declare -r GIT_URL=ssh://git@domain.com/sample_repo.git
declare -r GIT_KEY=/var/www/.ssh/deploy_push.pem
declare -r GIT_DIR=/usr/local/sample_app
declare -r DEV_SERVERS=weblinux-dev01
declare -r STAGE_SERVERS=weblinux-stage