Skip to content

Instantly share code, notes, and snippets.

View nathanborror's full-sized avatar

Nathan Borror nathanborror

View GitHub Profile
The Department of Mad Scientists (Michael Belfiore)
- Highlight Loc. 184-92 | Added on Friday, January 01, 2010, 05:28 PM
The United States spent $651 billion on defense-related activities in 2009. That’s more than half of the U.S. discretionary budget, and more than the military budgets of China, Russia, and Europe combined. No less a figure than President Eisenhower—the same president who launched NASA and DARPA—warned of the direct cost to the nation’s citizens of extreme military spending. “Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed,” he told the American Society of Newspaper Editors in a speech that was broadcast over television and radio in April 1953. “The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is
#!/usr/bin/env python
#
# some bits stolen from Travis Cline's http://github.com/traviscline/git-branchdescriptions
#
import os
import re
import sys
from subprocess import Popen, PIPE
def comment_saved_handler(sender, instance, created, **kwargs):
"""
Signal handler to populated comment count fields.
Bound to 'comment_count' field, should probably be checking for a field annotation in the model.
"""
if 'comment_count' in [f.name for f in instance.content_object._meta.fields]:
instance.content_object.count = instance.content_object.comments.count()
instance.content_object.save()
from django.contrib.comments.models import Comment