This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author: Dirceu Pereira Tiegs <[email protected]> | |
# | |
# Script to roll dices (used to play D&D). Example: | |
# | |
# >> require 'dices' | |
# >> 3.d6 | |
# => 10 | |
# >> 3.d6+7 | |
# => 14 | |
# >> 1.d4+2.d8+1.d12+3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author: Dirceu Pereira Tiegs <[email protected]> | |
# | |
# Script usado para gerar nomes de tavernas | |
# | |
class Array | |
def pick | |
self.sort_by {rand}[0] | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ibook:~ dirceu$ # primeiro criamos uma working copy do repositório | |
ibook:~ dirceu$ # isso pode demorar porque o git copia o projeto TODO, | |
ibook:~ dirceu$ # todas as revisões | |
ibook:~ dirceu$ git-svn clone https://dev.xxxxx/projetofoo/trunk projetofoo | |
ibook:~ dirceu$ cd projetofoo | |
ibook:projetofoo dirceu$ # agora é fazer alterações e commits a vontade... | |
ibook:projetofoo dirceu$ vi meuarquivo.py | |
ibook:projetofoo dirceu$ git commit -a -m 'Alterando foo porque bar' | |
ibook:projetofoo dirceu$ # ... e branches! 'git branch NOME' cria um novo branch, | |
ibook:projetofoo dirceu$ # 'git checkout NOME' troca de branch. o branch padrão é 'master' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.test import TestCase | |
from django.core import mail | |
from myproject.myapp.views import send_some_emails | |
class FooTestCase(TestCase): | |
def test_email_subject(self): | |
send_some_emails() | |
self.assertEquals(mail.outbox[0].subject, 'My subject') | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Script to generate a Malvados (http://www.malvados.com.br) feed. | |
# | |
# Author: Dirceu Pereira Tiegs <[email protected]> | |
# | |
# You can see the result on http://dirceu.info/malvados.xml. | |
# | |
require 'rssify' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from StringIO import StringIO | |
from Products.CMFCore.utils import getToolByName | |
from zope.app.component.hooks import setSite | |
from zope.app.component.interfaces import ISite, IPossibleSite | |
from Products.Five.site.localsite import enableLocalSiteHook | |
from collective.lead.interfaces import IDatabase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ATSAObjectField_get(self, instance, **kwargs): | |
__traceback_info__ = (self.getName(), instance, kwargs) | |
storage = self.getStorage(instance) | |
original_storage = config.storages.get(instance.__class__.__name__ + self.getName(), None) | |
if original_storage: | |
storage = original_storage | |
try: | |
kwargs['field'] = self | |
r = storage.get(self.getName(), instance, **kwargs) | |
except AttributeError: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ tree > t | |
$ python repeated_files_on_tree.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The following code can be used to delete an object that is return POSKeyErrors | |
# on a ZODB database. Run it using 'zopectl debug'. Tested with Zope 2.9. | |
container_id = '/path/to/container' | |
screwed_object_id = 'screwed_obj' | |
from ZODB.POSException import POSKeyError | |
import transaction | |
obj = app.unrestrictedTraverse(container_id) | |
obj._objects = tuple(filter(lambda i,n = id: i['id'] != n, obj._objects)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.yml | |
twitter.xml | |
last_id.txt |
OlderNewer