This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"" Source your .vimrc | |
"source ~/.vimrc | |
"" -- Suggested options -- | |
" Show a few lines of context around the cursor. Note that this makes the | |
" text scroll if you mouse-click near the start or end of the window. | |
set scrolloff=5 | |
" Do incremental searching. | |
set incsearch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# To use just run following command in shell: | |
# wget -O - https://gist.githubusercontent.com/katyukha/5c5db1216f9a9f6f41d9b0361822f7fe/raw/create_env.bash | bash -s | |
# install vim config (if it is not installed yet) | |
if [ ! -d $HOME/.vim ]; then | |
CURRENT_DIR=$(pwd); | |
cd $HOME; | |
git clone https://github.com/katyukha/.vim.git .vim; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xmlrpclib | |
try: | |
from lxml.etree import XMLPullParser | |
except ImportError: | |
LXMLParser = None | |
else: | |
class LXMLParser: | |
def __init__(self, target): | |
self._parser = XMLPullParser(events=('start', 'end'), | |
huge_tree=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if six.PY3: | |
# There are no need to implement any aditional logic for Python 3.3+, because | |
# there base class 'object' already have implemented '__dir__' method, | |
# which could be accessed via super() by subclasses | |
class DirMixIn: | |
pass | |
else: | |
# implement basic __dir__ to make it assessible via super() by subclasses | |
class DirMixIn(object): | |
""" Mix-in to make implementing __dir__ method in subclasses simpler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
randpw(){ < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-16};echo;} | |
# usage: | |
# randpw [length] | |
# randpw - generate password with 16 characters | |
# randpw 8 - generate password with 8 characters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# function to remove packages related to kernel version | |
function remove_kernel { | |
sudo dpkg --purge linux-headers-$1-generic; | |
sudo dpkg --purge linux-headers-$1; | |
sudo dpkg --purge linux-image-$1-generic; | |
} | |
function list_old_kernels { | |
for kname in $(dpkg -l "linux-[hi][em]*[0-9]\.[0-9]\.[0-9]-*" | awk '{print $1 " " $2}' | grep -v -e "^un*" | grep -Po "([0-9]+\.[0-9]+\.[0-9]+\-[0-9]+)" | sort -u --version-sort); do | |
if [ "$kname" == $(uname -r | grep -Po "([0-9]+\.[0-9]+\.[0-9]+\-[0-9]+)") ]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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` |
NewerOlder