View pivotpandas.py
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
df = pd.read_excel('/home/ecarreras/Desktop/l.xls')
table = pd.pivot_table(
df, index=['empresa', 'producto'], values=['price_subtotal'], aggfunc=[np.sum], fill_value=0
)
table_tots = table.groupby(level='empresa').sum()
View test_show_qt_window.py
from PyQt4.QtGui import QApplication, QMainWindow, QDialog, QHBoxLayout
from PyQt4.QtCore import SIGNAL
from Koo.Rpc import Rpc
from Koo.Common import Api
from Koo.Common import Localization
Localization.initializeTranslations()
from Koo.Dialogs import WindowService
x = Rpc.session.login('http://admin:admin@localhost:8069', 'test_1522167327')
View clean_rq.py
from redis import StrictRedis
from rq.job import Job
from rq import push_connection, get_failed_queue
from collections import Counter
from tqdm import tqdm
stats = {'queue': Counter(), 'status': Counter()}
conn = StrictRedis.from_url()
push_connection(conn)
View gist:d40059004897436fb255840397f30379
from flask import Flask, request
import time
app = Flask(__name__)
@app.route('/ARequest', methods=['POST'])
def arquest():
print "Writing a post!"
with open('post-{}'.format(time.time()), 'w') as f:
View link_pygtk_venv.sh
View po_spliter.py
from babel.messages import catalog, pofile
SPLITS = 10
catalogs = [catalog.Catalog(locale='es_ES') for _ in range(0, SPLITS)]
with open('locales/es_ES/LC_MESSAGES/messages.po', 'r') as f:
po = pofile.read_po(f)
untranslated = [s.id for s in po if not s.string]
for idx, string in enumerate(untranslated):
c_idx = idx % SPLITS
View canvi_hora.py
from datetime import datetime
import calendar
def canvi_hora(year, month):
for d in range(calendar.monthrange(year, month)[1], 1, -1):
if datetime(year, month, d).weekday() == calendar.SUNDAY:
return d
def get_canvis_hora(year):
View fuck_xml.py
# Imports
import xml.etree.ElementTree as py_etree
import xml.etree.cElementTree as c_etree
text = "<foo>&fucking;</foo>"
# Exception
py_etree.fromstring(text)
"""
Traceback (most recent call last):
View fucking_poweremail.py
for i in range(rec.last_mail_id + 1, int(msg_count[0]) + 1):
if rec.rec_headers_den_mail:
typ, msg = serv.fetch(str(i), '(FLAGS BODY.PEEK[HEADER])')
method = getattr(self, 'save_header')
else:
typ, msg = serv.fetch(str(i), '(FLAGS RFC822)')
method = getattr(self, 'save_fullmail')
for mails in msg:
if type(mails) == type(('tuple', 'type')):
mail = email.message_from_string(mails[1])
View gen_autobj_from_clmag.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
import optparse
import csv
import time
parser = optparse.OptionParser(version="[GISCE ERP] Migrations")