Skip to content

Instantly share code, notes, and snippets.

View eneldoserrata's full-sized avatar

Eneldo Serrata eneldoserrata

View GitHub Profile
@eneldoserrata
eneldoserrata / gist:1b8a14feca66a3b52b0f
Created August 25, 2014 23:32
numbers to letters
from itertools import ifilter
UNIDADES = (
'',
'UN ',
'DOS ',
'TRES ',
'CUATRO ',
'CINCO ',
'SEIS ',
@eneldoserrata
eneldoserrata / sdq_cedula_rnc_validator.py
Last active December 18, 2015 00:58
Antes que nada las gracias a la gente de developers.do por su plugin en jquery https://github.com/hminaya/SDQ que fue de donde me fije para hacer esto Valida las identificaciones fiscales de la República Dominicana, Cédula de identidad personal y Registro nacional del contribuyente (RNC) en python
# -*- coding: utf-8 -*-
# Estas cedulas fueron emitidas por la JCE, pero no cumplen con el
# digito verificador, por lo cual deben ser verificadas por separado.
import csv
import cPickle
__author__ = 'eneldoserrata'
excepcionesCedulas = ['00000000018', '11111111123', '00100759932', '00105606543', '00114272360', '00200123640',
@eneldoserrata
eneldoserrata / cp_sqlalchemy_plugin.py
Last active December 20, 2015 02:49
cherrypy sqlalchemy plugin
from cherrypy.process.plugins import SimplePlugin
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base, declared_attr
from sqlalchemy.orm.scoping import scoped_session
from sqlalchemy.orm.session import sessionmaker
from sqlalchemy.schema import Column
from sqlalchemy.types import Integer
import sqlamp
import cherrypy
@eneldoserrata
eneldoserrata / remove_data.sql
Last active September 13, 2016 14:45
odoo clean data
DELETE FROM stock_pack_operation;
DELETE FROM stock_picking;
DELETE FROM stock_move;
DELETE FROM sale_order_line;
DELETE FROM sale_order;
DELETE FROM account_invoice_line;
DELETE FROM account_invoice;
DELETE FROM account_move_line;
DELETE FROM account_move;
DELETE FROM pos_order_line;
DELETE FROM account_partial_reconcile;
delete from pos_order;
delete from pos_session;
DELETE FROM stock_pack_operation;
DELETE FROM stock_picking;
DELETE FROM stock_move;
DELETE FROM sale_order_line;
DELETE FROM sale_order;
DELETE FROM account_invoice_line;
DELETE FROM account_invoice;
@eneldoserrata
eneldoserrata / cp_mako_plugin.py
Created July 23, 2013 00:09
cherrypy mako plugin
# -*- coding: utf-8 -*-
import cherrypy
from cherrypy.process.plugins import SimplePlugin
from mako import exceptions
from mako.lookup import TemplateLookup
# todo-eneldo Documentar
# todo-eneldo capturar exceptions
# todo-eneldo crear test units
server {
listen 443;
server_name fhisa.tabla.si;
access_log /var/log/nginx/fhisa.access.log;
error_log /var/log/nginx/fhisa.error.log;
ssl on;
ssl_certificate /etc/nginx/ssl/fhisa.crt;
ssl_certificate_key /etc/nginx/ssl/fhisa.key;
#Install wkhtmltopdf
cd /usr/local/src
wget https://downloads.wkhtmltopdf.org/0.12/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
tar xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
ln -s -f /usr/local/src/wkhtmltox/bin/wkhtmlto* /usr/bin/
cd ~
chown -R $OE_USER: /usr/local/src/wkhtmltox
chown -R $OE_USER: /usr/bin/
#Install wkhtmltopdf
cd /usr/local/src
wget https://downloads.wkhtmltopdf.org/0.12/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
tar xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
ln -s -f /usr/local/src/wkhtmltox/bin/wkhtmlto* /usr/bin/
cd ~
chown -R $OE_USER: /usr/local/src/wkhtmltox
chown -R $OE_USER: /usr/bin/
@eneldoserrata
eneldoserrata / gist:15846ecdb73fa9ba25ec1cbfc4a5fcd3
Created February 5, 2018 17:29
Como decargar archivos desde odoo usando una URL
class Binary(http.Controller):
@http.route('/web/binary/download_document', type='http', auth="public")
@serialize_exception
def download_document(self, model, field, id, filename=None, **kw):
""" Download link for files stored as binary fields.
:param str model: name of the model to fetch the binary from
:param str field: binary field
:param str id: id of the record from which to fetch the binary
:param str filename: field holding the file's name, if any