Skip to content

Instantly share code, notes, and snippets.

@javouhey
javouhey / gist:1146042
Created August 15, 2011 11:06
How to search for all tickets assigned to a person's name
common_cols_pretty = """dtLastUpdated
dtOpened
dtResolved
dtClosed
sTitle
sStatus
ixStatus
sEmailAssignedTo
sPersonAssignedTo"""
@javouhey
javouhey / gist:1148448
Created August 16, 2011 04:43
getters and setters for python classes
class Person(object):
@property
def fullname(self):
return "%s - %s" % (self.forename, self.surname)
@fullname.setter
def fullname(self, value):
self.forename, self.surname = value.split(" ", 1)
@javouhey
javouhey / gist:1269646
Created October 7, 2011 06:56
How to find out who called a function in python by inspecting stackframes
import inspect
frame,filename,line_number,function_name,lines,index=\
inspect.getouterframes(inspect.currentframe())[1]
print(frame,filename,line_number,function_name,lines,index)
@javouhey
javouhey / gist:1274485
Created October 10, 2011 02:06
How to find out the site-packages directory for my setup
python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
@javouhey
javouhey / gist:1274844
Created October 10, 2011 08:08
How to inspect a javascript object like python's dir
http://stackoverflow.com/questions/4652559/in-javascript-is-their-a-way-to-inspect-an-objects-methods-and-attributes-such-a
(1)
var dir = '';
for (var i in obj) dir += 'obj[' + i + '] = ' + obj[i];
alert(dir);
http://stackoverflow.com/questions/5357442/how-to-inspect-javascript-objects
@javouhey
javouhey / gist:1294642
Created October 18, 2011 05:04
Generate click handlers for buttons
def _buttons_js(results):
""" Adds the 'click' handler to all the 'add to cart' buttons """
t4 = Template("""$('#cart-{{product_group}}-{{oldid}}').live('click', function(event) {
article_id = get_article_id( '{{product_group}}', '{{oldid}}' );
$(this).attr('disabled', true);
publish_message( '{{product_group}}', '{{oldid}}', 'Added ' + article_id + ' !' );
});
""")
@javouhey
javouhey / gist:1321598
Created October 28, 2011 04:09
Disable foreign key checks in MySql
SET foreign_key_checks = 0;
SET foreign_key_checks = 1;
To check the status after/before the change:
mysql> show variables;
Originally:
https://gist.github.com/7565976a89d5da1511ce
Hi Donald (and Martin),
Thanks for pinging me; it's nice to know Typesafe is keeping tabs on this, and I
appreciate the tone. This is a Yegge-long response, but given that you and
Martin are the two people best-situated to do anything about this, I'd rather
err on the side of giving you too much to think about. I realize I'm being very
critical of something in which you've invested a great deal (both financially
@javouhey
javouhey / gist:1464466
Created December 12, 2011 02:54
Referring to class variables from other class variables in a python class
class A(object):
a = 1
b = 2 + a
@javouhey
javouhey / gist:1513638
Created December 23, 2011 08:57
Filter spec for a date
class ExpiryFilterSpec(ChoicesFilterSpec):
def __init__(self, f, request, params, model, model_admin,
field_path=None):
super(ExpiryFilterSpec, self).__init__(f, request, params, model,
model_admin,
field_path=field_path)
self.field_generic = '%s__' % self.field_path
self.field_generic_not = 'not_' + self.field_generic