Code snippets represent a large portion of my posts. They generally include, "While working on X, I ran into issue Y and came up with this solution Z…" type descriptions for context. Interesting as that might be, they aren't critical. What they are is time consuming to produce. I post less often because of that. Inspired by the HashRocket's Today I Learned blog1, I'm changing my approach and dropping the backstory.
Starting today, code snippet posts will fall under umbrella "Today I Learned: …" titles. There will still be enough context to make sense, but the specific reasons I went down any particular rabbit hole will be greatly reduced. I figure this will cut two thirds or more off writing time.
Less muss, less fuss, more posts.
Today I Learned from the crew at Hashrocket - Frequent snippet posts. It's only been going for a couple months. There's already a bunch of nice things though. Good stuff.
Here's a great development nugget courtesy of the book Design Patterns in Ruby1.
The standard Ruby library contains a module called ObjectSpace that:
… contains a number of routines that interact with the garbage collection facility and allow you to traverse all living objects with an iterator.
It's that last part that's of interest and leads us to the method:
Pass it a class name and it'll iterate over all existing objects of that type. That means we can find specific objects from anywhere in an application2.
Here's the start of a simplistic example: A Character class that stores first and last names and a few instances that aren't assigned to anything.
To demonstrate the method, let's produce a list of everyone who's not a member of the Robinson family. This is done by passing ObjectSpace.each_object the Character class name and examining the last_name property of each object returned in the loop.
Running that, we get our list:
There are usually explicit connections between objects that need to know about each other. When there's not and it would be tricky to implement one, ObjectSpace.each_object can provide a nice bridge.
Design Patterns in Ruby "… a guide to solving real-world problems with Ruby." I'm only seven chapters in. If I get nothing else out of it, it's already been worth the price of admission. This is one of those books that fits squarely into both the "Wish I'd read it years ago" and the "To re-read repeatedly" categories.
Update on January 5, 2017 - Important to point out this is probably a bad idea most of the time. I was just intrigued to see that it was possible.
Innovation in light bulb design continues apace. The leading example is variable color, smart phone controlled LED lights. Yes, seriously1. Even incandescents, the dinosaur of light bulbs, are evolving.
Traditional incandescents work by suspending a little piece of tungsten inside a vacuum.
A new technique recently hit the scene. Instead of a filament, a smaller halogen bulb is wired inside the main bulb.
Illumination, Russian Doll Style.
There is also a hole in the screw cap. This would prevent a traditional incandescent from working, but the halogens don't need an external vacuum. My guess is that this acts as a pressure valve or ventilation. Whatever the case, it certainly looks intentional.
This whole hybrid-halogen concept looks like someone ended up with a ton of surplus halogen bulbs and said, "Hey, what if we jury-rigged these inside of a standard bulb?" and everyone laughed. Until they did it and it worked.
Definite points for creativity.
Philips Hue - Personal Wireless Lighting - "The bulbs, the bridge and the app will change the way you use light. Forever. Experiment with shades of white, from invigorating blue/white to cozy yellow/white. Or play with all the colors in the spectrum."
Posted: January 24, 2015 - Updated: March 04, 2015
Updated March 4, 2015 with more cruft identifiers including several from Windows machines
This is my reference for patterns to exclude when moving files around with rsync. It ignores system cruft that doesn't need to be copied and throws me off when it shows up on my FreeNAS server. I'm posting it to have access to it from anywhere and for anyone else who might find it useful.
Welcome to the new and improved redesign of alanwsmith.com!
Don't be surprised if you can't tell the difference.
This redesign is almost entirely behind-the-scenes. Instead of my hand-build code, the page templates now use a framework called Bootstrap1. The biggest change is that the site is now "responsive" (i.e. it'll resize itself nicely for laptops, tablets and phones).
Making the site phone friendly has been on the back-burner for some time. It moved up the priority list dramatically when Google sent me an email titled "Fix mobile usability issues". It said, in part:
Google systems have tested 66 pages from your site and found that 97% of them have critical mobile usability errors. The errors on these 64 pages severely affect how mobile users are able to experience your website. These pages will not be seen as mobile-friendly by Google Search, and will therefore be displayed and ranked appropriately for smartphone users.
Or, put another way, "Your site is about to disappear from the internet."
There's still plenty of rough edges, but the foundation is in place. According to the testing tool2, I still have work to do to appease the robots. In the mean time, it does look way better on phones.
Bootstrap was started by Twitter. In the old days, making your own site framework was a right of passage. With all the little gotchas of making sites look good across different sites of displays, it doesn't make sense. Bootstrap or another framework like Foundation are the way to go.
The Mobile-Friendly Test lets you see what Google things about your page. It's one of many they provide to help build better sites. Something they excel at.