Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View diyan's full-sized avatar

Oleksii Diian diyan

View GitHub Profile
@diyan
diyan / build_tasks.py
Created October 27, 2011 17:53
Buld script for Python project (virtualenv, pip with requirement file, pylint, py.test, coverage, Jenkins CI) which could be executed from both system and virtual environment
import os
import sys
# One or several build tasks could be executed from Jenkins CI as following:
# #!/bin/bash
# cd $WORKSPACE/release_system/src/build/
# python -c 'from build_tasks import *; code_analysis(); run_tests()'
class BuildEnvironment(object):
@diyan
diyan / gist:1561460
Created January 4, 2012 18:57
PyLint configuration for one of our Python project
[MESSAGES CONTROL]
# Disable the following messages:
# C0111: Missing docstring. Used when a module, function, class or method has no docstring.
# Some special methods like __init__ doesn't necessary require a docstring.
# R0903: Too few public methods (%s/%s). Used when class has too few public methods, so be sure it's really worth it.
# W0232: Class has no __init__ method. Used when a class has no __init__ method, neither its parent classes.
# R0201: Method could be a function. Used when a method doesn't use its bound instance, and so
# could be written as a function.
# W0511: Used when a warning note as FIXME or XXX is detected.
@diyan
diyan / gist:1572015
Created January 6, 2012 19:27
Pre and Post build action for .NET/COM component which will be used in Classic ASP application
echo NOTE that right now pre build action will be executed...
@echo off
set APP_CMD="C:\Windows\System32\inetsrv\AppCmd.exe"
echo STEP 1. Recycle IIS 7 Application Pool named SomeAppPool because it may locked .NET assembly with COM component
%APP_CMD% recycle apppool /apppool.name:SomeAppPool
===============================================================================================
echo NOTE that right now post build action will be executed...
@diyan
diyan / gist:1627530
Created January 17, 2012 17:09
ServiceStack.Redis benchmarks
**Workstation with Intel Core i5 (3.2 GHz, dual core) CPU, 8 GB RAM**
**Test #1. ServiceStack.Redis load test. This C# client shown results better than BookSleeve library.**
1.000.000 records (1 thread) - 00:00:31 (Server RAM - 365,152 K; Client RAM - 34,596 K)
1.000.000 records (32 thread) - 00:00:15 (Server RAM - 364,664 K; Client RAM - 39,512 K)
10.000.000 records (1 threads) - 00:05:50 (Server RAM - 3,608,376 K; Client RAM - 69,960 K)
10.000.000 records (32 threads) - 00:03:00 (Server RAM - 3,609,368 K; Client RAM - 76,963 K)
@diyan
diyan / compile_stdlib.py
Created February 7, 2012 12:07
Compile all Python scripts into single StdLib.dll .NET assembly
# Script below is based on following post:
# IronPython: EXE compiled using pyc.py cannot import module "os" - Stack Overflow
# http://stackoverflow.com/questions/6195781/ironpython-exe-compiled-using-pyc-py-cannot-import-module-os
import sys
sys.path.append('d:/projects/SomeProject/Libs/IronPython')
sys.path.append('d:/projects/SomeProject/Libs/IronPython/Lib')
sys.path.append('d:/projects/SomeProject/Libs/IronPython/Tools/Scripts')
import clr
@diyan
diyan / gist:1844503
Created February 16, 2012 12:25
Tools and libraries which I prefer to use in .NET stack

Tools and libraries which I prefer to use in .NET stack:

Development Tools:
  • Git / Jenkins CI / Redmine
  • Visual Studio 2010 / ReSharper for .NET/C# coding
  • Jet Brains PyCharm for Python coding
Environment:
  • .NET 4.0 / MySQL
  • Amazon EC2 / Amazon RDS (works on top of MySQL)
@diyan
diyan / gist:2850866
Created June 1, 2012 09:54
Python with PowerShell Remoting (Windows equivalent for Unix ssh sessions)
# Note that target_env.login and target_env.password is global variables
# Maybe I should add this into Fabric project (http://docs.fabfile.org/en/1.4.2/index.html).
# This is complicated task for sure but it would be nice if Fabric could use ssh under Linux and PowerShell Remoting under Windows.
def remote_sh(target_host, command_text, ignore_error=False):
print('run PowerShell script block at {0}: {1}'.format(target_host, command_text))
command_text = command_text.replace('"', '\'')
@diyan
diyan / install_graphite.sh
Last active February 1, 2017 10:59
HOW-TO install Graphite into fully isolated Python virtual environment
## HOW-TO install Graphite into fully isolated Python virtual environment
# required for twisted binary extensions
sudo apt-get install python-dev
root=/usr/local/graphite_app
mkdir ${root} && cd ${root} && virtualenv env --prompt=\(graphite_env\)
source env/bin/activate
# NOTE that latest version of pyparsing (2.0.0) was failed to install
@diyan
diyan / fabric_monkey_patch.py
Created August 1, 2012 16:12
Fabric monkey patch for replacing SSH transport with WinRM
import sys
import time
import subprocess
import types
from tempfile import TemporaryFile
def remote_sh(target_host, login, password, command_text, stdout=None, stderr=None):
winrs_text = 'winrs -remote:{0} -username:{1} -password:{2} -noprofile {3}'.format(
target_host, login, password, command_text)
#print('winrs text: {0}\n'.format(winrs_text))
@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/'