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
[alias] | |
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative | |
recent = !git branch --sort=-committerdate --format='%(color:bold green)%(HEAD)%(color:reset)%(color:yellow)%(refname:short)%(color:reset)|%(color:bold green)%(committerdate:relative)|%(color:cyan)%(subject)|%(color:magenta)%(authorname)%(color:reset)' --color=always | column -ts '|' |
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
Go to Bitbucket and create a new repository (its better to have an empty repo) | |
git clone [email protected]:abc/myforkedrepo.git | |
cd myforkedrepo | |
Now add Github repo as a new remote in Bitbucket called "sync" | |
git remote add sync [email protected]:def/originalrepo.git | |
Verify what are the remotes currently being setup for "myforkedrepo". This following command should show "fetch" and "push" for two remotes i.e. "origin" and "sync" | |
git remote -v |
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 pytz | |
from datetime import datetime | |
other_tz = pytz.timezone('Europe/Madrid') | |
# From random aware datetime... | |
aware_datetime = datetime.utcnow().astimezone(other_tz) | |
# 1. Change aware datetime to UTC and remove tzinfo to obtain an unaware datetime | |
unaware_datetime = aware_datetime.astimezone(pytz.UTC).replace(tzinfo=None) |
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
class EnDecoder(object): | |
"""Text casting helper.""" | |
DEFAULT_ENCODING_TYPES = ['ascii', 'utf-8'] # [+aggressive .. -aggressive] | |
DEFAULT_NORMALIZE_FORMS = ['NFKD', 'NFD', 'NFKC', 'NFC'] # [-aggressive .. +aggressive] | |
@staticmethod | |
def _decode(txt, encoding_types=None): | |
""" | |
Decode a text string with the encoding methods that are indicated. |
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 timedelta_datetime_list(date_list, reverse=False, expanded_info=False): | |
""" | |
Gives the difference between the date element and the next one. | |
:param date_list: list of datetime/date objects | |
:type date_list: list | |
:param reverse: How the list should be sorted list.sort(reverse=<True,False>) | |
:type reverse: bool | |
:param expanded_info: Adds the first and second date on the yield as return parameters. | |
:type expanded_info: bool |
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
-- show running queries (pre 9.2) | |
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(query_start, clock_timestamp()), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
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
class IterPickledFile(list): | |
def __init__(self, file_name, seek_list=None, del_file=False): | |
self.file_name = file_name | |
self._del_file = bool(del_file) | |
seek_list = isinstance(seek_list, list) and seek_list or [] | |
if not seek_list: | |
with open(self.file_name, 'r') as f: | |
while True: | |
try: |
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 version="1.0" ?> | |
<openerp> | |
<data> | |
<record model="ir.actions.client" id="action_highcharts_qweb"> | |
<field name="name">QWeb Widget With HighCharts</field> | |
<field name="tag">my_module.my_action</field> | |
</record> | |
<menuitem id="random_id" name ="HighCharts View" action="action_highcharts_qweb" /> | |
</data> | |
</openerp> |