Skip to content

Instantly share code, notes, and snippets.

View Shide's full-sized avatar

Eduardo de Miguel Shide

View GitHub Profile
@Shide
Shide / .gitconfig
Created May 28, 2021 13:42
Cool Gitconfig Aliases
[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 '|'
@Shide
Shide / github-to-bitbucket
Last active May 25, 2021 10:44 — forked from sangeeths/github-to-bitbucket
Forking a Github repo to Bitbucket
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
@Shide
Shide / changing_aware_datetimes.py
Created May 21, 2020 08:38
Changing timezones
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)
@Shide
Shide / endecoder.py
Created January 10, 2019 15:54
Text converter between unicode and str.
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.
@Shide
Shide / date_tools.py
Created December 11, 2018 12:26
Datetime Tools
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
@Shide
Shide / postgres_queries_and_commands.sql
Created March 13, 2018 09:11 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- 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%'
@Shide
Shide / iter_pickled_file.py
Last active March 9, 2018 13:37
Generator File Pickled
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:
@Shide
Shide / highcharts_action.xml
Last active August 26, 2016 08:09
OpenERP HighCharts Widget Example
<?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>