So on one of our test servers I was doing some heavy performance testing when I noticed a strange OperationalError exception message in the Debug console for Django:
I went digging around and sure enough I had all kinds of locks when I attempted:
mysql> SHOW PROCESSLIST;
So next I checked the status of the free space available to learn than the partition that the mysql data was on was completely full. So, shutdown mysql and relocated the data to another partition with plenty of room:
Not to say that this is a bug in django but rather a bug in how I had written some of my models.
Just wanted to point out a quick tip for anyone else who may have done the same thing as me as well as for any of the django experts out there that might suggest a better way.
What was happening was that I began to notice a wild discreptancy between two datetime columns in several models. They should have been identical, however, they were both getting their dates differently:
What seems to be happening with this configuration is that datetime.now() is executed once when the server starts (and/or the module is imported) instead of what I thought would happen when I initially wrote these and that datetime.now() would get executed anytime an instance of the model was created and saved as a new record.
My solution was to override the save method:
...
date_column_one = models.DateTimeField()
...
def save(self):
if not self.id:
self.date_column_one = datetime.now()
super(MyModel, self).save()
...
I am sure there is probably a better way and if you know of one, please leave a comment or send me an email and let me know!
I’ve been digging into Cocoa to learn how to write native applications on the Mac. Objective-C is actually pretty nice, once I get past the funky bracket syntax and the notion of sending messages instead of calling functions.
I have struggled to find good sources of help and information on the web. Maybe that is in part because this is a pretty narrow segment of developers (versus something like Ruby, Python, or C#). That being said, I have found pretty fast and good help can be found on the cocoa-dev mailing list.
I first set out to learn about and build a preference pane to capture configuration values that I want for the application I am building (more on that to come once I am ready to unveil what I have planned). In doing so I found some resources that helped quite a bit, yet left a little to be desired.
First the documentation was written for 10.4, but I was working with 10.5, so some of the screenshots were throwing me off. Second, there was one detail in particular that was troubling me and if it weren’t for help from a John Stiles from the cocoa-dev listserv, I would still be spinning.
The one little trick that was keeping me spinning was un-checking “Release When Closed” on the Panel Attributes inspector page:
If you don’t do that then all will work well until you got to select the application menu after closing the preference pane window. The application will freeze and then crash. Makes perfect sense now that it was pointed out to me.
There is a new book on Peepcode that covers git pretty deeply and in a way that is more easily digestible for the non-Linux hacker. It also comes with quite a bit of video demonstrating concepts in the book. Both very high quality items are sold together for a very low $9.
This graphic from page 10 of the book made me smile:
After some tireless searching for a git command that would yield a listing of local commits that have not been pushed to a target, I popped into the #git IRC channel and posed the question. I was promptly answered by Mikachu:
There is a fantastic series of statements/questions from George Will to Senator Obama, most of them highlighting what George refers to as Obama’s cognitive dissonance.
You say, “The insurance companies, the drug companies, they’re not going to give up their profits easily when it comes to health care.” Why should they? Who will profit from making those industries unprofitable? When pharmaceutical companies have given up their profits, who will fund pharmaceutical innovations, without which there will be much preventable suffering and death? What other industries should “give up their profits”?
ExxonMobil’s 2007 profit of $40.6 billion annoys you. Do you know that its profit, relative to its revenue, was smaller than Microsoft’s and many other corporations’? And that reducing ExxonMobil’s profits will injure people who participate in mu-tual funds, index funds and pension funds that own 52 percent of the company?
You say John McCain is content to “watch [Americans'] home prices decline.” So, government should prop up housing prices generally? How? Why? Were prices ideal before the bubble popped? How does a senator know ideal prices? Have you explained to young couples straining to buy their first house that declining prices are a misfortune?
Telling young people “don’t go into corporate America,” your wife, Michelle, urged them to become social workers or others in “the helping industry,” not “the moneymaking industry.” Given that the moneymakers pay for 100 percent of American jobs, in both public and private sectors, is it not helpful?
You favor raising the capital gains tax rate to “20 percent or 25 percent.” You say this will not “distort” economic decision making. Your tax returns on your 2007 income of $4.2 million show that you and Michelle own few stocks. Are you sure you understand how investors make decisions?
During the ABC debate, you acknowledged that when the capital gains rate was dropped first to 20 percent, then to 15 percent, government revenues from the tax increased and they declined in the 1980s when it was increased to 28 percent. Nevertheless, you said you would consider raising the rate “for purposes of fairness.” How does decreasing the government’s financial resources and punishing investors promote fairness? Are you aware that 20 percent of taxpayers reporting capital gains in 2006 had incomes of less than $50,000?
You want “to reduce money in politics.” In February and March you raised $95 million.
When looking at this, it would seem that Obama doesn’t understand that much when it comes to macro-economics.