Skip to content

Instantly share code, notes, and snippets.

@etienned
etienned / export.py
Created September 21, 2018 04:23
Function to export a requirements.txt from poetry
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 16:06
Playbook to test osx_defaults module.
- 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 December 28, 2018 20:39
Tests and code for CFPreferences class of Ansible osx_defaults module.
#!/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 January 21, 2015 15:41
Sublime log for codeintel problem
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 November 21, 2022 13:56
Simple function to extract text from MS XML Word document (.docx) without any dependencies.
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 March 22, 2013 03:51
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
# HG changeset patch
# User etienne <[email protected]>
# 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 March 6, 2013 18:25
Patch to add quantization support to JPEG in PIL.
# HG changeset patch
# User etienne <[email protected]>
# 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 June 15, 2012 03:30
jQuery plugin that change element type, preserving attributes.
(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 18:28
CLI for the PHP version of 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