@toddmotto if you're not ashamed of your code when you revisit it, you're not a good developer. #truestorybro
— Txus Ordorika (@txusinho) October 12, 2016
Borderline obsessive about how I do things
I rewrite the whole damn thing.
When code that worked, doesn't anymore. Because of something I did. Probably.
if team == 'Falcons':
odds = '100 to 1'
elif team == 'Patriots':
odds = '3 to 1'
elif team == 'Titans':
odds = 'maybe next year'
super_bowl_odds = {
'Falcons': '100 to 1',
'Patriots': '3 to 1',
'Titans': 'maybe next year'
}
odds = super_bowl_odds.get(team, 'Unknown team')
Stack Overflow: "Better optimization technique using if/else or dictionary"
# requirements.txt
requests==0.2.0
def plus_one_week(dt):
"""
Returns the given date plus 7 days.
"""
return dt + timedelta(days=7)
from ..utility.date import plus_one_week
# ...further down the page
c = self.create(user_id=user.id,
type='invitation',
redirect_url=app.config['JOIN_LINK'],
expires_on=plus_one_week(datetime.now()))
class BeveragesView(TemplateView):
template_name = 'drinks.html'
def get_context_data(self, **kwargs):
context = super(BeveragesView, self).get_context_data(**kwargs)
# leave the templates the same or change?
context['drinks'] = get_beverages(self.request)
return context
While I'm not sure arranging your Kanban board by "stages of grief" is good for morale, I still love this: https://t.co/NUeSkiyabH pic.twitter.com/32lmsRg8ie
— Richard Seroter (@rseroter) October 17, 2016
Easing your annoyance can be good for the business
http://russelljanderson.com/refactor-slides