Skip to content

Instantly share code, notes, and snippets.

Avatar

Etienne Desautels etienned

View GitHub Profile
@etienned
etienned / export.py
Created Sep 21, 2018
Function to export a requirements.txt from poetry
View export.py
from poetry.console.application import Application
from poetry.semver import parse_constraint, VersionUnion
def export_requirements(tag=False):
app = Application()
installed_repo = app.poetry.locker.locked_repository(True)
output = []
@etienned
etienned / test_osx_defaults.yml
Created May 26, 2017
Playbook to test osx_defaults module.
View test_osx_defaults.yml
- hosts: localhost
gather_facts: false
tasks:
- name: Key-Value Command > Boolean
osx_defaults: domain=com.ansible.test key=BooleanKeyValue value=true
- name: Key-Value Command > Integer
osx_defaults: domain=com.ansible.test key=IntegerKeyValue value=42
- name: Key-Value Command > Float
@etienned
etienned / test_osx_defaults.py
Last active Dec 28, 2018
Tests and code for CFPreferences class of Ansible osx_defaults module.
View test_osx_defaults.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
from base64 import b64decode
import calendar
import contextlib
import datetime
import os
import re
import shutil
@etienned
etienned / gist:ba8ee1451a375cefce44
Created Jan 21, 2015
Sublime log for codeintel problem
View gist:ba8ee1451a375cefce44
theme loaded
app ready
pre session restore time: 1.39609
using gamma: 1 (err: 0)
Traceback (most recent call last):
File "./sublime_plugin.py", line 195, in on_modified
File "./sublime_plugin.py", line 154, in run_timed_function
File "./sublime_plugin.py", line 194, in <lambda>
File "./SublimeCodeIntel.py", line 1503, in on_modified
File "./SublimeCodeIntel.py", line 1394, in update
@etienned
etienned / extractdocx.py
Last active May 4, 2020
Simple function to extract text from MS XML Word document (.docx) without any dependencies.
View extractdocx.py
try:
from xml.etree.cElementTree import XML
except ImportError:
from xml.etree.ElementTree import XML
import zipfile
"""
Module that extract text from MS XML Word document (.docx).
(Inspired by python-docx <https://github.com/mikemaccana/python-docx>)
@etienned
etienned / accessibility_patch.diff
Created Mar 22, 2013
Patch to Fancybox that add accessibility improvement by disabling background tabbing and return focus to tabbed element after close. This feature can be turn on/off by setting the tabFocus option. Check this pull request for more info: https://github.com/fancyapps/fancyBox/pull/526
View accessibility_patch.diff
# HG changeset patch
# User etienne <etienne.desautels@gmail.com>
# Date 1363923789 14400
# Node ID af13fed965d5dadc1b1cac9eb73a0be664f0101f
# Parent 532037e7911b9e9f7c06715117ad61873c6ccb9a
Added option to use tab key to focus prev, next and close navigation in fancybox.
diff --git a/mmac/utils/static/mmac/js/libs/fancybox/jquery.fancybox.js b/mmac/utils/static/mmac/js/libs/fancybox/jquery.fancybox.js
--- a/mmac/utils/static/mmac/js/libs/fancybox/jquery.fancybox.js
+++ b/mmac/utils/static/mmac/js/libs/fancybox/jquery.fancybox.js
@etienned
etienned / jpeg_quant.diff
Created Mar 6, 2013
Patch to add quantization support to JPEG in PIL.
View jpeg_quant.diff
# HG changeset patch
# User etienne <etienne.desautels@gmail.com>
# Date 1318347470 14400
# Node ID 4d7b7e9cb7a8346c712e4e65d5037d90f81b9716
# Parent cd403356263f039a4a48a1111c7f5cc38686e481
Towards adding quantization tables options to the JPEG encoder.
diff --git a/PIL/JpegImagePlugin.py b/PIL/JpegImagePlugin.py
--- a/PIL/JpegImagePlugin.py
+++ b/PIL/JpegImagePlugin.py
@etienned
etienned / changeElementType.js
Created Jun 15, 2012
jQuery plugin that change element type, preserving attributes.
View changeElementType.js
(function($) {
$.fn.changeElementType = function(newType) {
this.each(function() {
var attrs = {};
$.each(this.attributes, function(idx, attr) {
attrs[attr.nodeName] = attr.nodeValue;
});
$(this).replaceWith(function() {
@etienned
etienned / csstidy
Created May 25, 2012
CLI for the PHP version of CSSTidy
View csstidy
#!/usr/bin/env php
<?php
/**
* CSSTidy - Command Line Interface (CLI)
*
* Command Line Interface that try to mimic as much as possible the C++ CLI
* version of csstidy. It should be a drop in replacment for the C++ CLI that is
* no longuer maintain. New settings like css_level are added.
*
* Copyright 2005, 2006, 2007 Florian Schmitz
You can’t perform that action at this time.