Skip to content

Instantly share code, notes, and snippets.

View sharoonthomas's full-sized avatar

Sharoon Thomas sharoonthomas

View GitHub Profile
@sharoonthomas
sharoonthomas / gist:993335
Created May 26, 2011 15:09
Test for tryton dispatcher
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
import unittest
import threading
from functools import partial
from trytond.tests.test_tryton import POOL, DB_NAME, USER, CONTEXT, \
install_module
@sharoonthomas
sharoonthomas / bitbucket.py
Created June 4, 2011 04:54
Script to display all issues in all projects/repositories of bitbucket
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Get all your bitbucket issues at once-Fetches/Displays your bitbucket issues
-
:copyright: (c) 2011 by Openlabs Technologies & Consulting (P) Limited
:license: BSD, see LICENSE for more details.
-
The username and password for this program can be set in multiple ways.
-
1. Set environment variable
class StringField(BaseField):
"""A unicode string field.
"""
def __init__(self, regex=None, max_length=None, min_length=None, **kwargs):
self.regex = re.compile(regex) if regex else None
self.max_length = max_length
self.min_length = min_length
super(StringField, self).__init__(**kwargs)
@sharoonthomas
sharoonthomas / gvs.js
Created September 26, 2011 12:04
Google visualisation.js
function drawVisualization() {
var data = new google.visualization.DataTable();
data.addRows(6);
data.addColumn('string', 'State');
data.addColumn('number', 'Customers');
data.setValue(0, 0, 'US-FL');
data.setValue(0, 1, 200);
data.setValue(1, 0, 'US-MN');
data.setValue(1, 1, 300);
data.setValue(2, 0, 'US-NJ');
@sharoonthomas
sharoonthomas / find.sh
Created December 8, 2011 12:37
Find and update git folders recursively
find . -mindepth 1 -maxdepth 1 -type d -exec sh -c "cd \"{}\" && python setup.py install" \;
@sharoonthomas
sharoonthomas / cached_property.py
Created January 25, 2012 01:02
Python cached property implementation
class cached_property(object):
"""A decorator that converts a function into a lazy property. The
function wrapped is called the first time to retrieve the result
and then that calculated result is used the next time you access
the value::
class Foo(object):
@cached_property
def foo(self):
@sharoonthomas
sharoonthomas / tryton_wsgi.py
Created March 12, 2012 01:03
Tryton WSGI Application script
# -*- coding: utf-8 -*-
"""
wsgi_app
A wsgi application script to load tryton and also the middleware required
to support Cross Origin Resource Sharing (CORS).
Inspired by the original work at http://codereview.tryton.org/92001/ by
Cedric.
@sharoonthomas
sharoonthomas / example.js
Created March 12, 2012 02:03
Tryton Model Proxy example
var ir_ui_menu_proxy = new Ext.createByAlias('proxy.tmodel', {
modelName: "ir.ui.menu"
});
ir_ui_menu_proxy.doRequest(
'search_read',
[['parent', '=', false], 0, 1000, null, ['name', 'childs']],
// Callback
function(result) {
console.log(result);
});
@sharoonthomas
sharoonthomas / gist:2779418
Created May 24, 2012 04:28
Example for stack level
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
test
Testing the warning stack level usage
:copyright: (c) 2012 by Openlabs Technologies & Consulting (P) Limited
:license: BSD, see LICENSE for more details.
"""
@sharoonthomas
sharoonthomas / gist:2785473
Created May 25, 2012 02:52
Serve files based on google authentication
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""
Authentication proxy for Tornado to use Google apps authentication to
serve the files in a protected location. Ideal to serve files like
sphinx documentation behind a password.
:copyright: (c) 2011 by Openlabs Technologies & Consulting (P) Limited
:license: BSD, see LICENSE for more details.
"""