Skip to content

Instantly share code, notes, and snippets.

View drkpkg's full-sized avatar
🏠
Working from home

Felix Daniel Coca Calvimontes drkpkg

🏠
Working from home
View GitHub Profile

Install dependencies for build

sudo apt install git wget nodejs npm python3 build-essential libzip-dev python3-dev libxslt1-dev python3-pip libldap2-dev python3-wheel libsasl2-dev python3-venv python3-setuptools node-less libjpeg-dev xfonts-75dpi xfonts-base libpq-dev libffi-dev fontconfig

Install wkhtmltopdf

@drkpkg
drkpkg / Passthrough.py
Created December 3, 2022 03:41
Gpu passthrough
# Import libraries
import os
# Define function to detect GPU
def detect_gpu():
# Use lspci command to list PCI devices
result = os.popen("lspci | grep -i 'vga\|3d\|2d'").read()
# Extract GPU information from lspci output
if result:
@drkpkg
drkpkg / controller_decorator.py
Last active March 3, 2022 15:12
Odoo Http controller decorator
# Custom decorator
def check_origin_and_token(func):
@functools.wraps(func)
def secure_func(self, **kwargs):
headers = http.request.httprequest.headers
origin = '{}://{}'.format(headers.environ['wsgi.url_scheme'], headers['Host'])
_logger.info('New request from Origin:{}'.format(origin))
if 'X-Token' not in headers:
_logger.error('X-Token not found in headers')
@drkpkg
drkpkg / multiarray.py
Created October 21, 2020 00:38
Multi array to array python
arr = [4, 5, [6, [8, 9]], 10]
arr2 = []
def do_array(a, b):
print(a)
for i in a:
if(isinstance(i, list)):
do_array(i, b)
else:
b.append(i)
@drkpkg
drkpkg / remaster.md
Created May 28, 2020 05:11
Remasterizacion de distros ubuntu

Remasterizar una ISO de

Ubuntu

Esta es la documentación de como remasterizar una Iso Con Ubuntu en modo live Cd. Se vera los siguientes

puntos:

Contenido
class ProductTemplateKit(models.Model):
_inherit = 'product.template'
international_code = fields.Char('Codigo Internacional')
is_kit = fields.Boolean(
string='Es kit',
default=False)
product_combo_ids = fields.One2many('product.combo', 'product_parent_id', 'Combo de productos')
class ProductCombo(models.Model):
# This came up with a huge problem for days, but i resolve it.
# The main problem is the limitation in form in odoo. Mostly of this are not in the official documentation,
# so maybe you will feel a bit blind sometimes, but I feel you bro.
# Basically works for partner_id relation for many2one
# PART ONE
# Create a class res_partner.py
class ResPartner(models.Model):
"""This part is the easy part, @api.model overrides to name_get (optional) and name_search."""
_inherit = 'res.partner'
@drkpkg
drkpkg / size.py
Last active August 26, 2023 13:59
Dynamic size report invoice odoo
"""
Dynamic size in account_invoice report
Just send the account_invoice_line_id take the len() and multiply it with 7 (millimeters)
This example is simulating the paper of a supermarket invoice, the default size in my country is 24 millimeters for a correct
format, but you can change it!
How it works: You need pass this method inside the qweb report sending the lines.
"""
#Qweb
<t t-esc="o.change_size_page(o.lines)"/>
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Vista de formulario -->
<record model="ir.ui.view" id="contadesk_fv_factura_form">
<field name="name">Virtual Invoice</field>
<field name="model">contadesk.factura.virtual</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Virtual Invoice" version="7.0" create="0">
@drkpkg
drkpkg / Sudoku.java
Last active May 12, 2017 00:32
Sudoku class
package sudoku;
import java.util.LinkedList;
public class Sudoku {
public void DoSudoku(int [][] board, int row, int column) {
if(isFinish(board)){showBoard(board); return;}
if(row >= board.length) return;
if(column >= board[row].length){