Skip to content

Instantly share code, notes, and snippets.

View guewen's full-sized avatar

Guewen Baconnier guewen

View GitHub Profile
@guewen
guewen / cache.sql
Last active May 18, 2018 12:37
PostgreSQL maintenance queries
-- Needs pg_buffercache
select count(*) from pg_buffercache;
@guewen
guewen / s3sync.py
Last active August 29, 2015 14:24
Sync logs from S3
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Dowload new log files from S3.
New files are compressed with gzip and only new files are downloaded.
"""
from __future__ import print_function
@guewen
guewen / Dockerfile
Created July 15, 2015 09:28
Odoo Runbot Dockerfile
# Dockerfile
FROM ubuntu:14.04
# Set the locale
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# Install dependencies
@guewen
guewen / keybase.md
Created October 12, 2016 11:08
keybase proof

Keybase proof

I hereby claim:

  • I am guewen on github.
  • I am guewen (https://keybase.io/guewen) on keybase.
  • I have a public key ASAQTfK_7H26dnaTrYfE2YF_iXZotEEMvW97PWhFgilG2Ao

To claim this, I am signing this object:

@guewen
guewen / ir_http.py
Created January 19, 2017 15:53
Log Odoo cache statistics
# -*- coding: utf-8 -*-
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
import logging
import random
import threading
from collections import defaultdict
@guewen
guewen / normalize_query_function.sql
Last active October 16, 2019 09:07
pg_stat_statements normalization
CREATE OR REPLACE FUNCTION normalize_query(IN TEXT, OUT TEXT) AS $body$
SELECT
regexp_replace(
lower($1),
-- Remove IN values
'in\s*\([,\s\?]*\)', 'in (...)', 'g' )
;
$body$
LANGUAGE SQL;
@guewen
guewen / load_file.py
Last active January 16, 2023 12:19
odoo: load data file from shell
from odoo.tools import convert_file
convert_file(env.cr, 'account_invoice_sent', 'wizards/account_invoice_state_view.xml', {}, mode='update', kind='data')
env.cr.commit()
def reload(addon, path):
from odoo.tools import convert_file
convert_file(env.cr, addon, path, {}, mode='update', kind='data')
env.cr.commit()
@guewen
guewen / benchmark_odoo_recordset_union.py
Last active May 4, 2022 08:38
benchmark odoo recordset union
# to run in odoo shell
import timeit
code_recordset = """
result = env['product.product'].browse()
for record in records:
result |= record
"""