Skip to content

Instantly share code, notes, and snippets.

View alorence's full-sized avatar

Antoine Lorence alorence

View GitHub Profile
@alorence
alorence / odoo_backup.py
Last active October 12, 2021 08:11
Very simple script to dump a named Odoo database into restorable zip file (with filestore)
import base64
import os.path
import sys
from datetime import datetime
from xmlrpc.client import ServerProxy
full_host = os.getenv("ODOO_HOST", "http://localhost:8069")
master_pwd = os.getenv("ODOO_MASTER_PASSWORD")
if master_pwd is None:
@alorence
alorence / python_corpus.md
Last active April 21, 2020 04:05
Curated list of articles to understand complex topics

The Definitive Guide to Python import Statements | Chris Yeh

https://chrisyeh96.github.io/2017/08/08/definitive-guide-python-imports.html

The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) – Joel on Software

https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/

Python and Django Logging in Plain English

https://djangodeconstructed.com/2018/12/18/django-and-python-logging-in-plain-english/

An A-Z of useful Python tricks

@alorence
alorence / element_tree_xpath.py
Created August 30, 2018 12:59
An example of namespace management and simple Xpath search with ElementTree
# -*- coding: utf-8 -*-
from __future__ import print_function
import xml.etree.ElementTree as ET
xdoc = """
<ns:response xmlns:ns="http://myserver.example.com">
<ns:return>
<example>
<inner>Some text here</inner>
@alorence
alorence / bootstrap4-grid.html
Created January 2, 2018 16:02
Visualize various responsive predefined sizes in Bootstrap 4
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
@alorence
alorence / home_end_rebind.zsh
Last active May 21, 2017 08:23
Define custom binding for HOME and END keys, which are not well handled under some Windows SSH clients (mRemoteNG, PuTTY, MobaXTerm, etc.)
# Correct the behavior for HOME and END keys
bindkey '^[[1~' beginning-of-line
bindkey '^[[4~' end-of-line
@alorence
alorence / testdefault.py
Created May 17, 2016 16:24
Default django test module to use when pytest is the preferred test framework
# If your Django project uses pytest instead of the default django test framework, simply put this file in an application.
# It will be run when 'python manage.py test' is run and inform user that the project must be tested using pytest.
from django.test import TestCase
class UsePyTest(TestCase):
def test_use_pytest(self):
self.fail(
@alorence
alorence / cheatsheet.py
Created July 29, 2015 08:33
CheatSheet for some python synxtax
s = 'abcdefghij'
stmts = [
'len(s)',
's[0]',
's[1]',
's[0:]',
's[1:]',
's[0:3]',
's[:3]',
's[:-2]',
@alorence
alorence / CMakeLists.txt
Last active September 6, 2020 16:41
Two CMake macros returning the current date (format yyyy-mm-dd) and the current time (hh:mm:ss). These are completely useless since CMake 3.0 and the introduction of `string(TIMESTAMP)` command.
cmake_minimum_required(VERSION 2.8)
# Return the date (yyyy-mm-dd)
macro(DATE RESULT)
if(WIN32)
execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE ${RESULT})
string(REGEX REPLACE "(..)/(..)/(....).*" "\\3-\\2-\\1" ${RESULT} ${${RESULT}})
elseif(UNIX)
execute_process(COMMAND "date" "+%Y-%m-%d" OUTPUT_VARIABLE ${RESULT})
else()
@alorence
alorence / gist:8685116
Created January 29, 2014 10:17
Buggy Graphiti property sheet (Mac OS only)
package net.sf.orcc.xdf.ui.properties;
import org.eclipse.graphiti.ui.platform.GFPropertySection;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
public class TestPropertySection extends GFPropertySection implements
ITabbedPropertyConstants {