Skip to content

Instantly share code, notes, and snippets.

Avatar

Sharoon Thomas sharoonthomas

View GitHub Profile
@sharoonthomas
sharoonthomas / gist:993335
Created May 26, 2011
Test for tryton dispatcher
View gist:993335
#!/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 Jun 4, 2011
Script to display all issues in all projects/repositories of bitbucket
View bitbucket.py
#!/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
View gist:1200745
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 Sep 26, 2011
Google visualisation.js
View gvs.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 Dec 8, 2011
Find and update git folders recursively
View find.sh
find . -mindepth 1 -maxdepth 1 -type d -exec sh -c "cd \"{}\" && python setup.py install" \;
@sharoonthomas
sharoonthomas / cached_property.py
Created Jan 25, 2012
Python cached property implementation
View cached_property.py
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 Mar 12, 2012
Tryton WSGI Application script
View tryton_wsgi.py
# -*- 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 Mar 12, 2012
Tryton Model Proxy example
View example.js
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
Example for stack level
View gist:2779418
#!/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
Serve files based on google authentication
View gist:2785473
#! /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.
"""
You can’t perform that action at this time.