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″:
In my case, I’m also excluding all Podcasts and Voice Memos – I’m interested in Music here.
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.
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.
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.
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.
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!
Note: This is an honest personal endorsement. I was not paid or offered any incentives for this post.
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 →
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.
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!).
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
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'
See the socialaccount_socialaccount table for more in the 'extra_data' field.
# 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()
user.last_name = name.split()
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']
We did it! Inspired by this Mashable series, and using this tutorial, I built a little rig for spinning burning steel wool today, then took it out to the local park with Amy and Miles after dinner. Amy shot the images while Miles and I took turns spinning. Not nearly as scary as I thought it would be, but we still wore a protective hoodie and goggles, and brought along a gallon of water just in case (none of it needed).
These are all 30-second exposures. The hardest part is getting the distance right – tough to know in advance how far away the subject needs to be, so the tops/sides of several of these are off. More practice needed. Would also like to figure out how to change the color of the sparks. Any chemists in the house?