Sugar

August 10, 2010
Tags:

I wrote this in 2002 but I looked it up in old email so I could post it here to share with a friend.

I believe refined sugar to be unhealthy in a number of ways. This idea must be catching on because I heard a radio ad this week for sugar. The message was simple: eat sugar, only 16 calories per teaspoon or whatever. It made me laugh out loud!

Not only do I maintain my lower weight vs. higher when I scrupulously avoid sugar, my moods are more even (I think) and best of all, I lose my cravings for sweets. When I go a week or more without sugar, I no longer miss it. Then I can give myself a small treat, once a week or a few times a month, and still be fine.

The holidays, of course, are laden with sugar. I have made it through Halloween more than once with little or no sugar. The Halloween excess almost makes it too easy to sit out. It is no challenge.

This Christmas I was saving myself for mincemeat pie, but a neighbor caught me off guard by delivering a box of See’s candies with NUTS. I cut them all in half for all to share and sample, of course sampling quite a few myself. Fortunately they were not as good as I remembered.

Then a tin of chocolate chip cookies materialized under the tree on Christmas Day, from Sara. I would have preferred oatmeal, but nonetheless I started munching on those cookies. Mike did, too. They were a bit too sweet, and I guiltily ate around some of the chips and threw them away. I remember how crazy I thought Mike was ten years ago when he suggested making chocolate chip cookies with NO chips. Now I understand.

I was weaning myself from the cookies. I planned to finish the mincemeat pie for desserts — no one else likes it. Mike finished the chocolate chip cookies and said, “Oh, there is some other kind of cookies in here.” I asked what kind but he had not bothered to look.

When I looked later, I discovered pure treasure: Hello Dollies. I thought Nana just called them that, but I’ve seen the recipe in cookbooks. I wonder if Sara or Mother blessed me with these? I ate four at once, for lunch. After running errands, I ate three more. I will eat a proper dinner, but until then, I’m on a HD & water diet. Could you make HD into a complete meal by hiding protein powder between the graham-butter crust and chocolate layer? There is plenty of sugar and fat, other carbs, and trace protein in the nuts.

My only problem now is what to have for dessert: mincemeat pie or Hello Dollies?

Hello Dollies
These are also known as 6 Layer Bars - because the 6 ingredients in the
recipe are layered one by one in the pan. You can't get much easier than
that, and they are so good, too.

Ingredients:    

1/2 cup butter
1 1/2 cups graham wafer crumbs
1 cup chopped walnuts
1 cup chocolate chips
1 1/2 cups flaked coconut
1 can sweetened condensed milk (Eagle Brand, 300ml)

Directions:

Preheat oven to 350 degrees F. Melt butter in a 9 x 13 inch cake pan.
Remove from oven, and spread the melted butter evenly over the bottom of
the pan.

Sprinkle the graham wafer crumbs evenly over the melted butter.

Sprinkle walnuts over the graham wafer crumbs, then chocolate chips,
then coconut.

Pour sweetened condensed milk evenly over top of the coconut.

Return to oven and bake for about 25 minutes, until lightly browned on
top. Cut into small squares when cooled.
  • Share/Bookmark
0

Django, mod_wsgi, Apache and OS X

August 8, 2010
Tags:

Pretend Deployment Environment

There I was a few weeks ago (or was it months? years? no…) merrily working my way through Python Web Development with Django when I got to Chapter 7 and a Note that says the chapter assumes apache and mod_python setup, or some other deployment strategy, since the handy dandy development server doesn’t really cut it for the (toy) photo gallery.  See appendix.

I bet the django development server will work just fine for the exercise, and plan to try it out, but on the other hand I was happy to try running django with apache since that is what we do at work and one reason I am working through the book on my own time is to better understand the systems I manage at work.  The appendix mentioned wsgi as an alternative and again, since that is what we use at work, I went that way.

Good Enough

Or at least I tried to go that way… then I got lost, then back on track, then interrupted for days or weeks, and eventually with help from these two pages (1, from Chris, 2, from jesse ) I got it working perfectly!  Though I believe configured rather badly, which is to say I barely understand it and have some ideas about how to understand it better and make it better, listed below.  But to avoid losing my place again, here are the key bits that I know about that matter.

I do not recommend these bits as a good solution, merely as a waypoint on my learning path and an existence proof that it is possible to get it working.

In httpd.conf:

LoadModule wsgi_module     libexec/apache2/mod_wsgi.so

Include /private/etc/apache2/extra/httpd-vhosts.conf

I do not think it is necessary to use a virtual host, but that is the path I was on when I got it working.  The instructions from jesse (which I forgot about today until after I got it mostly working) show how to put all the configuration info in a conf file in your django project and then include it in httpd.conf.  But I put it in httpd-vhosts.conf and included it instead.

In /etc/hosts:

127.0.0.1       localhost mymach

In httpd-vhosts.conf:

<VirtualHost *:80>
    ServerName mymach
    ErrorLog "/private/var/log/apache2/mymach-error_log"
    CustomLog "/private/var/log/apache2/mymach-error_log" common

    <Directory /Users/marla/Projects/wdsite>
        AllowOverride All
        Options Indexes FollowSymLinks
        Order allow,deny
        Allow from all
    </Directory>

    Alias /adminmedia/ "/Library/Python/2.6/site-packages/django/contrib/admin/media/"
    <Directory "/Library/Python/2.6/site-packages/django/contrib/admin/media">
        Order allow,deny
        Options Indexes
        Allow from all
        IndexOptions FancyIndexing
    </Directory>

    WSGIScriptAlias / "/Users/marla/Projects/wdsite/wdsite.wsgi"

</VirtualHost>

In settings.py:

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/adminmedia/'

Note that the error file mymach-error_log was very useful in getting this working.  At one point I was getting this error message:

[Sat Aug 07 17:21:34 2010] [error] [client ::1] mod_wsgi (pid=14756): Target WSGI script '/Users/marla/Projects/wdsite/wdsite.wsgi' cannot be loaded as Python module.

The suggested test described here that was supposed to fail actually worked for me, which was amusing but also informative because it meant that the problem was not a python problem.  It turned out to be a sys.path problem which I hackily solved like so in my wdsite.wsgi file:

sys.path.append('/Library/Python/2.6/site-packages')

If I had not installed mod_wsgi.so using macports and then moved it over to /usr/libexec/apache2 because I wanted to use the apache installed with Snow Leopard, probably it would have looked for django in the right place without me telling it.

Improvements List

  • The biggest thing I know I want to change is to use virtualenv. That will probably include reinstalling mod_wsgi properly.  I would like to make a script that can set up the environment properly from scratch, too.  I think it would be fun to deploy the With Django chapter exercises on our family website hosted by HostGator.
  • In ch 7 of the book, the media dir inside the django project has an admin symlink to the installed django/contrib/admin/media, which seems nicer to me than the alias defined above in the httpd-vhosts.conf file going directly to the installed django.  Maybe I will try that before doing the virtualenv, but I hope that is one of the many things that will be nicely encapsulated by a virtualenv.
  • Share/Bookmark
2

The Grid

July 17, 2010
Tags:

I just finished reading The Grid: A Journey Through the Heart of Our Electrified World. It is an odd book.  I am picky about writing style, and at first the somewhat flippant voice of the author annoyed me.  But after a while I got used to it.  Then at one point, I wondered, who is this guy?

The inside jacket blurb explains everything.  A science writer – duh – Ph.D. in particle physics, landmark research at Fermi, etc. ok, written for a bunch of papers and magazines, and then: “He is also a playwright whose numerous productions have appeared at theaters in New York and Washington, D.C.  Schewe might be the first person to hold simultaneous membership in the American Physical Society, the Dramatists Guild, and the National Association of Science Writers.”

That explains the way the book is written, perfectly!

It reads like the kind of play that has a playful narrator who is a bit in your face, and also a vocal peanut gallery (or Greek chorus) always piping up with their philosophical digressions that are commentary on the plot, rather than part of the plot itself.  The peanut gallery in this book includes Thoreau (yes, Henry David), Lewis Mumford and Henry Adams.  Their commentary is usually worth reading, and it does make up only a small part of the book.  The rest of the story includes all the characters one would hope to meet in this story (not a formal history, we are warned) of the grid: Edison, Farraday, Henry, Tesla, Westinghouse, Insull, Lilienthal, with nods to Watt, Volta, Ohm, Hertz, Marconi, and other famous people who had interesting roles in the development of the electric grid, like Lenin.

I was pleased that he included Amory Lovins and surprised that he did not mention the Rosenfeld Effect explicitly.  I listened to a podcast of a recent talk by Amory Lovins in which he said something like: rewarding utilities for selling more electricity is dumb as a possum and we should stop doing that.  Some states have stopped, hence the Rosenfeld Effect, but most are still using the supply/demand equation like you might use for apples.

Why did I read this book?  A friend at work recommended it after I discovered that much as I want to learn about energy efficiency, I do not want to learn about it enough to study worthy texts like Unlocking energy efficiency in the U.S. economy on my own time.  Even though the data is rather fascinating, e.g. every single tiny column in the eye-chart graph of the energy efficiency supply curve in the U.S. looks like a business opportunity to me… it just puts me to sleep!  On my own time, I’d rather read something more entertaining (fiction, historical fiction, biographies) or creatively technical (Python Web Development with Django).

  • Share/Bookmark
1

LocalLink 0.5

July 8, 2010

At work I am helping build an intranet using a moinmoin wiki. Most of the company is a windows shop accustomed to sharing files on a “share drive” or by email of course. So it is important to show how to link to files on the share drive from the new wiki, where you can conveniently explain what that spaghetti pile of files is all about after all. Even introduce a view into the data that is organized and documented.

However, in documenting how to do this, the few enlightened folk using Firefox, and those of us in the Information Systems group using macs or linux and Firefox, were out of luck.  Click on a file:// link and you get…. nothing.  No error message.  No file.  Nothing happens.  Mouse over and the cursor changes to indicate that yes, indeed, you do have a link there.  But it is a non-operative link.  Bummer.

No problem, we documented a workaround: copy the text of the link, paste it into the url input bar, and the file will load.

But why is that?  It is rather awkward, and why does it work in the url input bar but clicking on the link just does nothing?

I stumbled on the answer first on a mediawiki page, and then a bit more googling lead me to the LocalLink 0.5 Add-on for Firefox.

Note, however, that some browsers, like Mozilla FireFox, will not follow file-URLs on pages that were loaded via HTTP.

I created an html file with a file:// link in it and put it in ~marla/Sites, which is a place for creating your own website if you turn on Web Sharing on os x.  I could thus verify that if I loaded the file in Firefox via http, the file:// link would do nothing.  If I loaded the same file via the file system (by typing it into the url bar), then the file:// link would work just fine.

So I installed LocalLink 0.5.  At first it also did not appear to do anything.  Another no-op?  But then before uninstalling it, I went to its homepage to see if I might be missing something, and sure enough, it adds a menuitem Open Link in Local Context… to the pop-up menu over a link.  So it preserves the mysterious no-op behavior if you click on a file link that is loaded via http, but it gives you this explicit way to load the file anyway, without doing a copy/paste of the url.  Operate at your own risk, obviously.

The add-on homepage has a nice, one paragraph explanation of the security concerns behind this odd nothing-happens behavior you get if you click on a file:// link loaded via http.  The explanation ends with:

The discussion about the consequences of the security model for the user tends to be heated. For more information see…

On an intranet at a small company, this is safe enough.  But the feature is for the browser, not scoped to work only within the safety of browsing inside the firewall.  So think-before-you-click certainly applies.

  • Share/Bookmark
0