Skip to content

Instantly share code, notes, and snippets.

View katyukha's full-sized avatar

Dmytro Katyukha katyukha

View GitHub Profile
class AttrDict(dict):
""" Simple class to make dictionary able to use attribute get operation
to get elements it contains using syntax like:
>>> d = AttrDict(arg1=1, arg2='hello')
>>> print d.arg1
1
>>> print d.arg2
hello
>>> print d['arg2']
@katyukha
katyukha / git-serve
Created April 24, 2014 08:29
# A simple bash script to share git repositories via standard git daemon application
#!/usr/bin/env bash
#
# A simple bash script to share git repositories via standard git daemon application
# run: "git_serv start [--listen <address>]" to start git daemon listening on address
# run: "git_serv share [repository_name]" inside a repository to share this repository.
# run: "git_serv del_share" inside a repository to stop sharing this repository
# run: "git_serv stop" to stop serving
#
# After first to steps your repository will be available to be cloned via command:
@katyukha
katyukha / openerp_int_field.py
Created April 29, 2014 12:57
OpenERP nullable int
# -*- coding: utf-8 -*-
from osv import fields
class integer_x(fields._column):
_type = 'integer'
_symbol_c = '%s'
_symbol_f = lambda x: x and int(x) or None
_symbol_set = (_symbol_c, _symbol_f)
_symbol_get = lambda self,x: x #or 0
@katyukha
katyukha / oev7-install.bash
Last active August 29, 2015 14:00
OpenERP Dev Install
#!/usr/bin/bash
#
# Bash script to instal dev version of OpenERP version 7 in local environment
#
# Ussage:
# bash install.bash [dest-dir]
#
# installs OpenERP into specified directory. automatically creates base config,
# run_server script, and script to create skeletons of new modules
@katyukha
katyukha / oev8-install.bash
Last active June 13, 2018 12:20
Odoo v8 Dev Install (WARNING: this is old unmaintained version. look at https://katyukha.gitlab.io/odoo-helper-scripts/)
#!/bin/bash
# WARNING: This is old and unmaintained version.
# for better quality install script look at: https://katyukha.gitlab.io/odoo-helper-scripts/
#
# Bash script to instal dev version of OpenERP version 8 in local environment
#
# Usage:
# bash install.bash [dest-dir]
@katyukha
katyukha / bulk_git.bash
Created May 27, 2014 10:09
Execute git command on all git repositories in specified directory
#!/bin/bash
# Update all git directories below current directory or specified directory
# Skips directories that contain a file called .ignore
#
# Params:
# $1 - directory to search repositories in
# all next will be passed to git
#
# Example:
# bash bulk_git.bash ~/projects/ status
@katyukha
katyukha / new_module.bash
Last active August 29, 2015 14:02
New module generator for OpenERP
#!/bin/bash
#
# Usage:
# new_module.bash <module_name> [root]
# Where 'root' arg is root directory to place module in. By default it is 'custom_addons'
#
# Guess directory script is placed in
F=`readlink -f $0`
@katyukha
katyukha / oe_generate_views.py
Last active August 29, 2015 14:03
Simple function to generate views on OE models
xml_template = """<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
%(views)s
</data>
</openerp>
"""
view_template = """
<record id="%(view_id)s_%(view_type)s_view" model="ir.ui.view">
def _price_rule_get_multi(self, cr, uid, pricelist, products_by_qty_by_partner, context=None):
context = context or {}
date = context.get('date') or time.strftime('%Y-%m-%d')
products = map(lambda x: x[0], products_by_qty_by_partner)
currency_obj = self.pool.get('res.currency')
product_obj = self.pool.get('product.template')
product_uom_obj = self.pool.get('product.uom')
price_type_obj = self.pool.get('product.price.type')
@katyukha
katyukha / uniqifiers-benchmark.py
Last active August 29, 2015 14:13
uniqifiers-benchmark
# Originaly got from http://www.peterbe.com/plog/uniqifiers-benchmark
import re
from sets import Set
def f1(seq): # Raymond Hettinger
# not order preserving
set = {}
map(set.__setitem__, seq, [])
return set.keys()