Skip to content

Instantly share code, notes, and snippets.

View exhuma's full-sized avatar
🐢
Slowly advancing on hobby projects

Michel Albert exhuma

🐢
Slowly advancing on hobby projects
View GitHub Profile
@exhuma
exhuma / gist:5290703
Created April 2, 2013 08:13
plovr-build-error-2
Buildfile: /home/exhuma/work/__libs__/plovr/build.xml
pre-compile:
compile:
[mkdir] Created dir: /home/exhuma/work/__libs__/plovr/closure/closure-templates/build/classes
[mkdir] Created dir: /home/exhuma/work/__libs__/plovr/closure/closure-templates/build/genfiles
[mkdir] Created dir: /home/exhuma/work/__libs__/plovr/closure/closure-templates/build/genfiles/com/google/template/soy/exprparse
[mkdir] Created dir: /home/exhuma/work/__libs__/plovr/closure/closure-templates/build/genfiles/com/google/template/soy/soyparse
[javacc] Java Compiler Compiler Version 5.0 (Parser Generator)
@exhuma
exhuma / gist:5858832
Created June 25, 2013 14:21
"Uploading" the contents of a variable using fabric.
def put_contents(value, remote_file, with_sudo=False):
"""
Uploads the contents of a variable to a remote file in a safe manner.
This will run ``mktemp`` on both the local and remote machine to reserve
unique temporary file names. Once the names are reserved, the file contents
are written as binary data into the local temp file. This local file is
then uploaded to the remote temp file and ultimately moved to the desired
destination.
@exhuma
exhuma / gist:5875917
Created June 27, 2013 12:02
Redmine query aimed at the "my page" route.
-- The following query conbines the task due-date with the priority and sorts with the combined value.
SELECT id, project_id, subject, due_date, status_id,priority_id,author_id, priority_id * EXTRACT(EPOCH FROM AGE(due_date))
FROM issues
WHERE assigned_to_id=3 OR
author_id=3 AND
status_id IN (SELECT id FROM issue_statuses WHERE NOT is_closed)
ORDER BY (priority_id * EXTRACT(EPOCH FROM AGE(due_date))) DESC NULLS LAST,
priority_id DESC;
class RepresentableBase(object):
"""
This class can be used by ``declarative_base``, to add an automatic
``__repr__`` method to *all* subclasses of ``Base``. This ``__repr__`` will
represent values as::
ClassName(pkey_1=value_1, pkey_2=value_2, ..., pkey_n=value_n)
where ``pkey_1..pkey_n`` are the primary key columns of the mapped table
with the corresponding values.
@exhuma
exhuma / client.bash
Created November 11, 2013 10:50
URL decoding in Flask
clear && curl http://localhost:5000/foo+bar
curl http://localhost:5000/foo%20bar
@exhuma
exhuma / example.py
Created December 11, 2013 08:33
Python urllib HTTPS request with proxies
HTTP_PROXY = {
"http": 'http://proxy.host:8888',
"https": 'http://proxy.host:8888'
}
def create(self, stanza, passwd):
'''
send xml data to ripe
return True on succes or HTTPError on error
@exhuma
exhuma / colourised_log_example.py
Last active September 1, 2017 12:04
Simple python log formatter for colourised terminal output.
"""
Example for a colourised logging output.
This example uses "blessings" to handle console escape sequences. ``blessings``
itself is a very harmless package in that it does not have any external
dependencies. And it's code-base is very clean and small.
The example extends the core logging formatter (logging.Formatter) and
colourises the complete line. This takes advantage of any upstream updates
related to logging. When writing this against Python 2.7, the parent code
┌─[10:15:19] michel@PC12-331
└─~/tmp› cat fabfile.py
import fabric.api as fab
fab.env.roledefs['staging'] = ['bbs-evolution.ipsw.dt.ept.lu']
fab.env.roledefs['prod'] = ['bbs-arbiter.ipsw.dt.ept.lu']
@fab.task
@exhuma
exhuma / idioms.rst
Last active August 29, 2015 13:55
Useful Python Idioms/caveats you might find useful if coming from another language.
@exhuma
exhuma / README.rst
Last active August 29, 2015 14:01
Closure RTE as part of a larger Component.

README

This example shows the use of a richtext-editor component as part of another, larger component.

The Problem

While the component shows up properly, the rendered IFRAME does not take up the full width of the editor. A wild guess is that the IFRAME is rendered before the width is available.