Skip to content

Instantly share code, notes, and snippets.

View marceloleiva's full-sized avatar

Marcelo Leiva marceloleiva

View GitHub Profile
@marceloleiva
marceloleiva / forms.py
Created July 7, 2019 01:44 — forked from eerien/forms.py
Comma Separated Values Form Field for Django. There are CommaSeparatedCharField, CommaSeparatedIntegerField.
from django import forms
from django.core import validators
from django.core.exceptions import ValidationError
class MinLengthValidator(validators.MinLengthValidator):
message = 'Ensure this value has at least %(limit_value)d elements (it has %(show_value)d).'
class MaxLengthValidator(validators.MaxLengthValidator):
message = 'Ensure this value has at most %(limit_value)d elements (it has %(show_value)d).'
@marceloleiva
marceloleiva / .env-example
Created April 3, 2020 00:08 — forked from gjbagrowski/.env-example
Django-environ example
# project-repo/app/settings/.env-example
#
# DJANGO
#
SITE_HOST=localhost:8000
USE_SSL=False
ALLOWED_HOSTS=localhost,127.0.0.1
SECRET_KEY=asdasd
DEBUG=true # never on production, will cause settings including api keys to leak
DJANGO_LOG_LEVEL=DEBUG
[options]
#
# WARNING:
# If you use the Odoo Database utility to change the master password be aware
# that the formatting of this file WILL be LOST! A copy of this file named
# /etc/odoo/openerp-server.conf.template has been made in case this happens
# Note that the copy does not have any first boot changes
#-----------------------------------------------------------------------------
# Odoo Server Config File - TurnKey Linux
@marceloleiva
marceloleiva / invoice_template.html
Created September 8, 2022 15:14
Odoo 14 Invoice Template
<div style="margin:0px;padding: 0px;">
<p style="padding:0px;font-size: 13px;">
Estimado/a
% if object.partner_id.parent_id:
${object.partner_id.name} (${object.partner_id.parent_id.name})
% endif
<br><br>
Junto con saludarle y agradecer su preferencia, adjuntamos
% if object.name:
factura <strong>${object.name}</strong>
@marceloleiva
marceloleiva / views.py
Created April 27, 2017 21:59 — forked from MrYoda/views.py
Python 3, Django 1.9+: Excel file creation and send on-the-fly with XlsxWriter & BytesIO
import xlsxwriter
from io import BytesIO
from django.http import StreamingHttpResponse
from django.views.generic import View
def get_foo_table_data():
"""
Some table data
"""
@marceloleiva
marceloleiva / chrome_headless.py
Created January 25, 2024 00:31 — forked from haranjackson/chrome_headless.py
Deploys the Python Selenium library and Chrome Headless to an AWS Lambda layer. You can specify the region, library version, and runtime. An example Lambda function is given.
from selenium.webdriver import Chrome
from selenium.webdriver.chrome.options import Options
options = Options()
options.binary_location = '/opt/headless-chromium'
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--start-maximized')
options.add_argument('--start-fullscreen')