Skip to content

Instantly share code, notes, and snippets.

View diyan's full-sized avatar

Oleksii Diian diyan

View GitHub Profile
@diyan
diyan / ps_utils.py
Created October 30, 2013 17:33
Change process name for Linux/BSD and using emulation for Windows
# This module based on procname.py module from python-cream project licensed under LGPL
# GitHub repo: https://github.com/cream/python-cream
# Source file: https://github.com/cream/python-cream/blob/master/cream/util/procname.py
# Copyright: 2007-2013, Sebastian Billaudelle <sbillaudelle@googlemail.com>
# 2010-2013, Kristoffer Kleine <kris.kleine@yahoo.de>
# This library is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# nxlog script that converts uid, gid into username and group name
#$id = getpwnam($name);
#$name = getpwuid($num);
#$name = getpwent();
#$gid = getgrnam($name);
#$name = getgrgid($num;
#$name = getgrent();
my %user_names = ();
@diyan
diyan / wheezy_web.py
Last active December 29, 2015 16:09
Simple script wheezy.web with content negotiation skeleton
from __future__ import unicode_literals
import json
from wheezy.http import WSGIApplication, HTTPResponse
from wheezy.routing import url
from wheezy.web.handlers import BaseHandler
from wheezy.web.middleware import bootstrap_defaults, path_routing_middleware_factory
from wsgiref.simple_server import make_server
class ResourceHandler(BaseHandler):
@diyan
diyan / bootstrap_env.sh
Last active December 30, 2015 12:09
Script that bootstraps dev environment for one Python project. Works on Windows (with installed Python 2.7.6 and msysgit) and Ubuntu Linux (out of box).
#!/bin/bash
set -e
OS=`uname`
mkdir -p pip_download_cache
if [ "$OS" == "Linux" ]; then
# libmysqlclient-dev -> mysql-python
# protobuf-compiler -> protobuf -> riak_pb -> riak
# libxml2-dev, libxslt1-dev -> lxml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="lshw-B.02.16" />
<style type="text/css">
.first {font-weight: bold; margin-left: none; padding-right: 1em;vertical-align: top; }
.second {padding-left: 1em; width: 100%; vertical-align: center; }
.id {font-family: monospace;}
@diyan
diyan / python_stack.md
Last active September 3, 2020 10:32
Tools and libraries which I prefer to use in Python stack

Tools and libraries which I prefer to use in Python stack

Development Environment

  • Ubuntu Linux for both development and production
  • Git version control system
  • Jenkins CI build server (but recently I'm moving to git server-side hooks with ssh from git server to dev/stage/prod servers)
  • Redmine bug tracking system
  • JetBrains PyCharm IDE

Production Environment

@diyan
diyan / python_wrappers_test_result.md
Last active January 3, 2016 10:19
C wrappers benchmark result on Asus Zenbook Prime UX31A / Core i7 3517U 1900 Mhz / Ubuntu 13.10 64 bit / Python 2.7.5 64 bit

Python C wrappers benchmark result on Asus Zenbook Prime UX31A / Core i7 3517U 1900 Mhz / Ubuntu 13.10 64 bit / Python 2.7.5 64 bit

Installation instructions for Ubuntu 13.10

$ git clone https://github.com/koder-ua/wrappers_test.git && cd $_
$ virtualenv . && . bin/activate
$ sudo apt-get install python-dev swig python-sip-dev libffi-dev libboost-python-dev python-sip-dev
$ pip install cython cffi
$ make

How to install Numba on Ubuntu 13.10

  • separate calls of "pip install" is a must
  • v0.11.0 was failed to install from PyPI, so I've used version from GitHub
$ sudo apt-get install python-dev llvm-dev
$ virtualenv numba && cd $_ && . bin/activate
$ pip install ipython cython numpy llvmpy
@diyan
diyan / flask_metrology.py
Last active August 29, 2015 13:56
Flask extension that collects metrics using Metrology and push them to Graphite
#NOTE This is alpha quality code. Works only on my workstation.
#NOTE Some details looks weird becase code is ported from my FlaskScales extension with minimal changes
from __future__ import unicode_literals
import os
import socket
from urlparse import urlparse
import logging
from flask import _request_ctx_stack
from flask.signals import got_request_exception, request_started, request_finished, template_rendered
from astrolabe import Interval
@diyan
diyan / selenium_patch.py
Created March 31, 2014 08:45
Selenium WebDriver monkey patch for using any CSS selector that jQuery supports.
"""
Selenium WebDriver monkey patch for using any CSS selector that jQuery supports.
Useful urls:
Inject the Sizzle CSS selector library. Selenium WebDriver - http://selenium.polteq.com/en/injecting-the-sizzle-css-selector-library/
Adding the Sizzle CSS Selector library in WebDriver - http://seleniumtestingworld.blogspot.com/2013/01/adding-sizzle-css-selector-library-and.html
"""
from __future__ import unicode_literals
from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver