Skip to content

Instantly share code, notes, and snippets.

Antoine Lorence alorence

View GitHub Profile
@alorence
alorence / odoo_backup.py
Last active Jul 8, 2019
Very simple script to dump a named Odoo database into restorable zip file (with filestore)
View odoo_backup.py
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 Apr 21, 2020
Curated list of articles to understand complex topics
View python_corpus.md

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 Aug 30, 2018
An example of namespace management and simple Xpath search with ElementTree
View element_tree_xpath.py
# -*- 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 Jan 2, 2018
Visualize various responsive predefined sizes in Bootstrap 4
View bootstrap4-grid.html
<!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
Define custom binding for HOME and END keys, which are not well handled under some Windows SSH clients (mRemoteNG, PuTTY, MobaXTerm, etc.)
View home_end_rebind.zsh
# 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
Default django test module to use when pytest is the preferred test framework
View testdefault.py
# 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 Jul 29, 2015
CheatSheet for some python synxtax
View cheatsheet.py
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 Jul 14, 2020
2 CMake macros returning the current date (format yyyy-mm-dd) and the current time (hh:mm:ss)
View CMakeLists.txt
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 Jan 29, 2014
Buggy Graphiti property sheet (Mac OS only)
View gist:8685116
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 {
You can’t perform that action at this time.