Skip to content

Instantly share code, notes, and snippets.

>>> def bar():
... bar.x = 3
...
>>>
>>> bar.x
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'function' object has no attribute 'x'
>>> bar()
>>> bar.x
In [19]: import xml.etree.ElementTree as ET
In [20]: x = u'<hello id="ŁðÆŊЧ"><world /></hello>'
In [21]: ET.tostring(ET.fromstring(x.encode('utf-8')), encoding='utf-8').decode('utf-8') == x
Out[21]: True
class UTCTimeAuditedModel(models.Model):
"""
Abastract model providing UTC time auditing.
Adds two fields `utc_created_at` set on first save of the instance, and
`utc_updated_at` updated on every item save to the current utc datetime
"""
utc_created_at = models.DateTimeField(editable=False, verbose_name=_(u"created at (utc)"))
utc_updated_at = models.DateTimeField(editable=False, verbose_name=_(u"updated at (utc)"))
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAABAEAvexstwva4ZI7j98B3qDYgtiVvTL/CLcL4i2vhuVvQCMW7qcCEelcos48cHTbE/D3bpuIR9HIjnSUNc+9DkUNjR3LxSllvf2EbG4c9SL8Y4geiXecQnBOeldKV50gMyVAuGaICf6fQal+LOtuJPY7m3nv8311ZCgxnDiauwVZfgS/zk0TsXari6h/28T3548IHjpNaPRJ0qJSy75f8hEHH7Xi1ldwK5u8C5CxFhu41rp6zMQUSsshvrg0HYRp7/HLk91/txGZcMMStaE1JZHmeltX32EJKCpXH9XpD/cBS8ABOdyp1t9oxTXmL8QsV8QsrZ9jrAbEYgfez8vKLE/5+ReD4rbExr0GIDjge3r9SP2tTLx0Ii6ReEk09ZydAW0TEeR4Hj+yhVdAqX611gafgQO4IAenPdvjPPs75QwatKUSXsJNQa8woE5+/t6lno4njDX+DR0cGbJ9buVTfXSNwDfqPCB2VoDW0dd2e7bkKAf9Jp/hzSLx+8sl+UsC4nEZC8AP5eJKu068W3es+1qU8VJ0TXObWMgYvX0X6bO0taCGcdddFhm/1C40mgFWw+fkF6scWB/P3RUVfypePSwfn5VfT7P0mmL35k43s2weTd+xCHmXlllcGW39U6DOmmErzCXlCzXlxRCGw67uJSq50VXIoeFdw4XrrtrSS/fNUrHR9n3nKcODNShqf3l0Fl+M/tH+XocF/71sf/qfIFolSrVHRSTGwVQIoRKjOgGrCdhfli+WkhR20YVE3uGddCH7/ZMuAUq4d5jyKF2PawhiIrdYG4ZhSOwvQ258Dyhg8sNam1SQ+YbZaCoDpp6a5zPIrHGPXACI6XC8ZICqIHL1yOX1C6EfI6ZsaKA2hDc4hbDBRLmFnf24a/3y0Y32zd6H0e8j5WTXpMwjvF1ctqgNqO6SuSYTLkkgTRSgu/wTM19tgWLu0RI6nw1vjBL8IHV0OdQ/inn1WUoyDwqcaaG3PKvMYaR5
cat << EOF >> ~/.mozilla/firefox/*.default/chrome/userContent.css
@-moz-document domain(mail.google.com)
{
/* GMail messages and textarea should use fixed-width font */
.gs .ii, textarea.dV {
font-family: MonoSpace !important;
font-size: 9pt !important;
}
}
EOF
Traceback (most recent call last):
File "/home/popego/envs/twitpie/lib/python2.5/site-packages/CherryPy-3.1.2-py2.5.egg/cherrypy/wsgiserver/__init__.py", line 1174, in communicate
req.respond()
File "/home/popego/envs/twitpie/lib/python2.5/site-packages/CherryPy-3.1.2-py2.5.egg/cherrypy/wsgiserver/__init__.py", line 544, in respond
self._respond()
File "/home/popego/envs/twitpie/lib/python2.5/site-packages/CherryPy-3.1.2-py2.5.egg/cherrypy/wsgiserver/__init__.py", line 556, in _respond
response = self.wsgi_app(self.environ, self.start_response)
File "/home/popego/deploy/branches/twitpie/categorizer/categorizer/apps/twitpie/web/server.py", line 56, in __call__
answer = self.twitterScoringService.categorize(user)
File "/home/popego/deploy/branches/twitpie/categorizer/categorizer/apps/twitpie/service/twitter.py", line 137, in categorize
#include <stdio.h>
int main(int argc, char **argv)
{
if (rand() % 534263 == 0) {
printf("You are extremely unlucky and this program is way too cool for you. Good bye\n");
return 1;
}
do_something_cool();
k@hirako ~/q/rvh % python uruguay.py
[{'date': datetime.date(2010, 3, 4),
'height': 328,
'port': 'Montecaseros',
'river': u'uruguay'},
{'date': datetime.date(2010, 3, 4),
'height': 298,
'port': 'Bella Union',
'river': u'uruguay'},
{'date': datetime.date(2010, 3, 4),
class WidgetHtml(models.Model):
POSITION_CHOICES = (
('content', 'Content'),
('sidebar', 'Sidebar')
)
content_type = models.ForeignKey('contenttypes.ContentType')
position = models.CharField(choices=POSITION_CHOICES, default='content')
html = models.TextField()
make_option('--boys-dont-cry', dest='silent_fail', action='store_true', default=False,
help=u"Don't exit on item update errors; try other items.")