Grosspop’s Theosophy

My grandfather (we called him by the German “Grosspop”) was an active Theosophist, and imparted wisdom from his readings to us boys every time we saw him. Theosophy was (is?) a sort of combined philosophy/religion that drew wisdom from all of the world’s religions, with a strong emphasis on reincarnation and positive thinking. “Ja Ja Scottie, every lifetime is just a stepping stone on the universal road – a thousand years is but a day of history” (read that to yourself in your thickest German immigrant voice).

Founded in 1875, it gained mild popularity in the U.S., and columns by theosophical writers appeared in pamphlets and newspapers all over the world. You don’t hear much about them anymore. We loved him dearly, though I think as kids we didn’t really know what to do with his musings.

On a recent visit to my parents’ house, my father handed down to me a scrapbook full of theosophical clippings Grosspop had gathered and saved over the years. I remember seeing Theosophy magazines around the house, but had never seen this scrapbook before. Honored to have this in the family; just wish I could have the opportunity to talk about Theosophy with him now, as an adult.

theosophy

How To Create iTunes Smart Playlists with Implied Criteria

If you’re not using Smart Playlists in iTunes, you should be. Whether you want to create simple query-backed playlists like “1920s Jazz” or “Funk and Soul”, Smart Playlists give you the ability to treat your iTunes music collection like an actual database. The beauty part is that Smart Playlists update themselves in real time as conditions change in your iTunes database.

A common/favorite Smart Playlist is the invaluable “Unplayed” list which lets you make sure you’ve heard everything in your collection at least once. To create an Unplayed list, just use the criteria “Plays is less than 1″:

unplayed2

In my case, I’m also excluding all Podcasts and Voice Memos – I’m interested in Music here.

But it gets more interesting (and more fun) than that.
Continue reading

Displaying Django User Messages with Angular.js

Django’s Messages framework is an elegant workhorse, and I’ve never built a Django site that didn’t use it for displaying success/failure/info messages to users after certain actions are taken (like logging in successfully or adding an item to a cart).

But wouldn’t it be cool if you could use that functionality client-side, delivering user messages to be processed as JSON data rather than statically outputting messages to generated HTML? On a recent project, I needed to do this because Varnish caching doesn’t let you mark page fragments as non-cacheable, so statically generated messages were not an option. But there are all sorts of reasons you might want to handle Django Messages client-side.

messagedisplay

Here’s how to accomplish the job in a really lightweight way, without the need for a full-blown REST API app like Django Rest Framework or Tastypie, and with Angular.js (which is, IMO, the best of the current crop of JavaScript application frameworks).
Continue reading

Inside the Black Box (Metamorphosis)

Metamorphosis_by_Almacan You learned in grade school that a caterpillar metamorphoses into a moth or butterfly. But what would you find if you were to cut open a chrysalis during that transformational stage? Would you find a half-caterpillar/half-butterfly hybrid? It’s a black box — you don’t know. Caterpillar goes in, butterfly comes out. We don’t ask what happens in between.

But we should.

What you would actually find would be little more than snot – a milky white mucous, with a few dark specs floating in it. The caterpillar dissolves itself into goo, and the cells of the goo reconstitute themselves into a moth or butterfly.

So what happens to the “personhood” of the being inside? Does one creature die while another is reborn, growing out of the mulch of its former self? Does the butterfly have any “memory” of the caterpillar it was? Here’s the really mind-blowing part: Scientists have figured out how to train a caterpillar (via subtle electric shocks) to turn and walk the opposite direction when a certain smell is introduced into their environment. When they later tested for the same learned ability in metamorphosed butterflies and moths, they found a 70% memory retention rate, which had lasted right through the goo phase. Turns out those little specks in the goo are clusters of brain cells, which save memories and then reproduce in the new being.

Monarch_chrysalis1 The biological weirdness continues: If we peel off the skin of a dead caterpillar, we find proto wings, laying in wait. They never emerge on the caterpillar itself, but when the rest of the insect dissolves to goo, the proto-wings cling to the walls of the chrysalis, and then attach themselves to the newly formed butterfly and continue their evolution. The caterpillar starts them, the butterfly finishes them.

The whole process is as spiritual as it is philosophical as it is scientific. Is there anything stranger or more magical in nature? (rhetorical question). Over dinner, as our family discussed this process, we wondered why it isn’t taught in grade school. Why do we just get the black box (input –> output) version? Always look behind the curtain.

Image above: Metamorphosis by Almacan

Inspired by this week’s “Black Box” episode of the always amazing Radiolab.

Miles’ First Poetry Slam

Felt so proud (and awed) by Miles at the New Years Day poetry slam when he pulled this out of his back pocket – not the usual kid/dada stuff he’s usually attracted to, but an honest-to-goodness heartfelt original poem, full of existential questioning. Forgot to record on NY day, so we re-created the reading at home yesterday so he could earn his Writer badge on DIY.org.

Photo365 for 2014

Family resolution: All three of us are doing Photo365 this year – one photo a day for an entire year. Easy when you’re out doing interesting things, a lot tougher when you settle back into the daily grind – everything starts to look the same and it’s on you to find new angles and lighting environments etc. I did the project back in 2011, and will be posting to Flickr again. Amy and Miles are also set up with Flickr accounts and empty sets, ready to go. Wish us luck!

You can track my 2014 progress here.

Servint vs. AWS

Note: This is an honest personal endorsement. I was not paid or offered any incentives for this post.

circuit I’ve been running Birdhouse Hosting for more than a decade now, and most of that time I’ve been hosting my services on a dedicated VPS at Servint.

I absolutely love the reliability and support I get through Servint, but every so often wonder whether I could reduce expenses by moving to Amazon Web Services, which lets you “pay as you go.” But every time I scratch the surface and try to do a real apples-to-apples comparison, I come to the same conclusion: Birdhouse is already in excellent hands, and I would not actually save money by moving, all things considered.
Continue reading

Mt. Tam Loop

Amazing day with family and friends, hiking a rigorous 6.5 mile loop through Mt. Tamalpais. Starting near Stinson Beach and working our way up to the (a) crest, through three distinct biomes (fern/rainforest/giant redwood, California Coastal, and dry rolling hills). Everyone worked for it, rewarded by more beautiful vistas around every corner. In the middle, a 15-foot ladder erected in the middle of Steep Ravine to accomplish the elevation. Kids talked and sung improvised songs and exhausted themselves and got stronger by the step. All of us appreciating yet another amazing trail in our own backyard.

tamalpais

Trail map

Flickr Set

DIY.org

diyorg diy.org is one of the best sites for keeping kids stimulated and engaged in the real world I’ve ever encountered. Beautifully designed and engineered, it breaks real-world maker skills into more than a hundred categories. When kids accomplish three tasks in a category, they get a virtual badge (you can purchase a real version of the badge for $5). This is the site I wish I had thought to build, dangit.

No idea what their monetization strategy is, but huge applause to the engineers and designers behind the project.

Miles (@Milezinator) is spending his Christmas break on a mad DIY badge quest (a blissful escape from Minecraft for us!).

django-allauth: Retrieve First/Last Names from FB, Twitter, Google

Of the several libraries/packages available for setting up social network logins for Django projects, I currently find django-allauth the most complete, with the best docs and the most active development. Doesn’t hurt that the lead dev on the project is super friendly and responsive on StackOverflow!

But not everything about it is intuitive. After wiring up Twitter, Facebook and Google as login providers, I found that first and last names were not being retrieved from the remote services when an account was successfully created. I also, frustratingly, could find only the most oblique references online to how to accomplish this.

There are a couple of ways to go about it – you can either receive and handle the allauth.account.signals.user_signed_up signal that allauth emits on success, or set up allauth.socialaccount.adapter.DefaultSocialAccountAdapter, which is also unfortunately barely documented.

I decided to go the signals route. The key to making this work is in intercepting the sociallogin parameter your signal handler will receive when an account is successfully created. I then installed a breakpoint with import pdb; pdb.set_trace() to inspect the contents of sociallogin. Once I had access to those goodies, I was able to post-populate the corresponding User objects in the database.

This sample code grabs First/Last names from Twitter, Facebook or Google; season to taste:


# When account is created via social, fire django-allauth signal to populate Django User record.
from allauth.account.signals import user_signed_up
from django.dispatch import receiver

@receiver(user_signed_up)
def user_signed_up_(request, user, sociallogin=None, **kwargs):
    '''
    When a social account is created successfully and this signal is received,
    django-allauth passes in the sociallogin param, giving access to metadata on the remote account, e.g.:

    sociallogin.account.provider  # e.g. 'twitter' 
    sociallogin.account.get_avatar_url()
    sociallogin.account.get_profile_url()
    sociallogin.account.extra_data['screen_name']

    See the socialaccount_socialaccount table for more in the 'extra_data' field.
    '''

    if sociallogin:
        # Extract first / last names from social nets and store on User record
        if sociallogin.account.provider == 'twitter':
            name = sociallogin.account.extra_data['name']
            user.first_name = name.split()[0]
            user.last_name = name.split()[1]

        if sociallogin.account.provider == 'facebook':
            user.first_name = sociallogin.account.extra_data['first_name']
            user.last_name = sociallogin.account.extra_data['last_name']

        if sociallogin.account.provider == 'google':
            user.first_name = sociallogin.account.extra_data['given_name']
            user.last_name = sociallogin.account.extra_data['family_name']

        user.save()