Pew Pew Laser Blog

Code. Glass art. Games. Baking. Cats. From Seattle, Washington and various sundry satellite locations.

The DL Element.

11.14.2017

At a conference earlier this year, I was asked what my favorite HTML element was. In fact, I do have one: the Definition List, along with its children Definition Term and Definition Description. The definition list is great because it provides an inherent semantic relationship between two elements - the term and the one or more descriptions. I feel like these elements are under-used; especially considering that they've been around since HTML 4.01.

I was going to invent a clever example to demonstrate the definition list, but I don't think I can do any better than the one provided by the Mozilla Developer Network:

Firefox
A free, open source, cross-platform, graphical web browser developed by the Mozilla Corporation and hundreds of volunteers.
The Red Panda also known as the Lesser Panda, Wah, Bear Cat or Firefox, is a mostly herbivorous mammal, slightly larger than a domestic cat (60 cm long).

Here is the source code for that:

<dl>
  <dt>Firefox</dt>
  <dd>A free, open source, cross-platform, graphical web browser developed by the Mozilla Corporation and hundreds of volunteers.</dd>
  <dd>The Red Panda also known as the Lesser Panda, Wah, Bear Cat or Firefox, is a mostly herbivorous mammal, slightly larger than a domestic cat (60 cm long). </dd>
</dl>

This shows one term (Firefox) along with two definitions of that term. Because it's a list, you can add as many groups of terms and definitions as needed for your content.

Virtual Reality.

10.23.2017

An attendee tests VR goggles at JSConf Last Call Folks love to post pictures of people using virtual reality (VR) googles, because everyone just looks so darn goofy with the headset on. But virtual reality really does have legs. In the past couple years, I've seen some truly convincing VR demos, and run across amazing uses for VR. (Photo by Matthew Bergman from JSConf Last Call; CC BY-NC-ND 2.0.)

This year, 3 friends and I played a demo of Marvel Powers United VR on 4 fully loaded Oculus setups with motion sensitive headsets and hand-held controllers. A single set of this gear costs multiple hundreds of dollars. When my system booted up, I was The Hulk - I was taller than everyone, my strides consumed feet like they were inches, and I could grab puny humans by their baseball-size skulls. It was unbelievably immersive; my brain easily believed in this new reality. I only experienced a little motion sickness; see (this for more on gender and VR motion sickness).

With any one of a number of electronic headsets and their companion apps, you can record and view panoramic or even 720° photos (some with even ambient sound). You can then view these high-resolution photos on the headset where moving your head moves the view of the photo. I've had demos of this too, and they're also very immersive. Can you imagine immersing your family in your vacation photos like this? Or remember that folks with disabilities are often technology's earliest adopters - virtual environments like this would be huge for those with severe anxiety or people who have trouble traveling.

Think about watching your favorite sports team; with 3D sound and picture captured right on the sidelines? Beyond games and entertainment, the universal on-line educational system of "Ready Player One" seems tantalizingly close. If you ever get a chance to try out some of this technology, I highly recommend checking it out.

There are more utilitarian ways to utilize VR. Google offers Cardboard, a $15 set of "glasses" that you insert your smartphone into. As just one example of apps for Cardboard, here is one which simulates a conference stage, so that you can practice your public speaking.

If you're a developer, this is a great time to start working with VR technologies. A great place to start is Shagufta Gurmukhdas's SeattleJS Conf 2017 talk about VR and Mozilla's A-Frame.

OSX Screenshots.

9.30.2017

In Windows, I use either the PrintScreen key or the Snip program for screenshots. But I can never remember the keyboard commands for screenshots in OSX, so here is a quick reference:

Both of the above methods will save the screenshot on your Desktop.

If I'm working in Firefox, I just use the built-in screenshot tools in Firefox too. (The files are saved in Downloads.)

Spinning Up a New GitHub Pages Site.

9.11.2017

Pages might just be one of my favorite things about GitHub. Though I often use them for lists of links to go along with my presentations, they are capable of much more complex static sites.

Here is a quick reminder of how to set up a new GitHub Pages site:

  1. Create a new repo on GitHub.
  2. Don't create any new files yet, even licenses or readmes. If you have already created files, then stash them.
  3. Clone that repo locally and check out a new gh-pages branch (git checkout -b gh-pages).
  4. Pop any files you've stashed. Add any other files you want in your repo.
  5. Commit the changes, and then push the gh-pages branch up to Github.

You're done! You can now view your new page at https://[your-user-name].github.io/[your-repo-name]/.

If you have somehow ended up with a master branch with commits, you can remove it thusly:

Free Images.

8.22.2017

Here are some sources for free images that you can use for your website, presentation, art project or whatever.

There are also companies which will give you free photos or credits on your first sign-up or periodically: iStock, Adobe Stock (fotolia), Shutterstock and Creative Market. And both Google and Flickr will let you search for CC licensed photos.

tinylab Flashlight.

8.2.2017

Photograph of a tinylab - an all-in-one arduino-compatible prototyping board. I've been fiddling around with my tinylab - an all-in-one prototyping board with an embedded Leonardo and a fair selection of components. I'd already got it working with Node and Johnny-Five. Next I wanted to do something which demonstrated interaction between the software and some real-world conditions.

Note that my tinylab (perhaps because it's an early crowd-funded version) doesn't have the breadboard shown in the current production versions of the tinylab. No worries - a mini breadboard (without the connector tabs) fits in there perfectly.

I made a "flashlight" - where an LED gets brighter when the hardware detects less ambient light. Since all the components on the tinylab are already built in, I didn't have to do any wiring. It's pretty easy to test by covering the photoresistor with your finger. Here is the code:

var five = require("johnny-five"), board, photoresistor;
var board = new five.Board();

board.on("ready", function(){

  var led1 = new five.Led(10);

  photoresistor = new five.Sensor({
    pin: "A2",
    freq: 500 // Data is polled every half second
  });

  maxLight = 750 // Set this to the "high" value of light in your room.
  minLight = 250 // Set this to the "low" value of light in your room.
  lightRange = (maxLight - minLight) // Will change for different rooms.

  photoresistor.on("data", function() {

    currentLight = this.value;
    ledValue = (((currentLight - minLight) * 255) / lightRange); 
    ledValue = Math.max(ledValue, 0);  
    ledValue = Math.min(ledValue, 255);

    console.log("Photosensor: " + this.value + "     ledValue: " + ledValue); 
    led1.fade(ledValue, 500); // Smooth transition of LED brightness

  });

});

You'll need to set the maxLight and minLight values for your environment.

With this experiment, you now have a way to read a value from your environment, report it to a computer, and act on it.

Subscriptions.

7.13.2017

I recently bought digital subscriptions to some "newspapers" (Seattle Times, NYT, WaPo) because I believe that creators should be paid for their work, that the news media is important in these political times, and because I wanted to move the motivation equation away from "ads and eyeballs". But I'm kinda disappointed at the less-than-premium treatment of paid subscribers by these organizations. Here are some examples of what I do not want: