I’m talking robots to a bunch of middle schoolers who visited Engadget HQ for Hour of Code.

life, coding, technology, outdoors, photography
I’m talking robots to a bunch of middle schoolers who visited Engadget HQ for Hour of Code.

Our office has an empty TV that isn’t being properly utilized at the moment. It’s definitely a #FirstWorldProblem, but it basically boils down to the fact that we have multiple displays that act as dashboards for our various services and properties.
Anyway, we had a spare television available to show whatever we wanted. THE ENTIRE INTERNET WAS OUR OYSTER and what better way to put it to use than to display a random assortment of animated GIFs.
Our troubles arose when we realized we had to manually change out the animated GIFs, as well as zoom in in via the attached machine’s web browser so that it would properly display images.
Annoying, right?
Cue superhero music
Some Javascript, CSS, and PHP came the the rescue!
We’re using CSS to set a background image (based on one of our animated GIFs) that fills up the entire display. Depending on the settings of your viewport, the image has the possibility of being severly cropped, but hey, whatever!
We’re using some Javascript calls (thank you so much, Stackoverlow) to display a new animated GIF every 20 seconds or so (or really, whatever time you want, but I’m using 20 seconds), as well as build an array of animated GIFs from our images folder.
Which brings us to PHP. We’re using PHP to scan the contents of the folder and then using some Jquery calls to periodically call our PHP script to rescan and rebuild the image array — this means you can drop new animated gifs into the /images folder (or remove them, but why would you even) and it will automagically add them to the Javascript array for random consideration.
Yes? Yes!
Upload this script to your favorite web server that supports PHP. Drop images (of the animated GIF variety) into the /images folder. Open up this page in your favorite browser on your favorite device. Cool? Cool!
So, what the heck does this thing look like? You can see it in action right here. (Make sure to set your browser to full screen presentation mode so you get the right effect).
GIFtv: http://dave.ly/stuff/giftv/
Hard G, dudes. It’s JIFF! I’m not wrong. You’re wrong.
Thanks to a few people who helped me try and figure this out.
tl;dr: Quickly generate multiple emails that you can send from your favorite mail client using mailto links and parsing data from various text files. (email addresses, email template, and optional redemption codes)
Recently, I had to contact 50 readers by email for a giveaway that we were running on our site. We’ve run similar sorts of events before and it’s always a tedious experience. It involves something like this:
There is! Just download this project to your favorite PHP compatible server (or run an app like MAMP on your machine) and open up the “make_email.php” script.
There are a few required files:
Once you have these text files filled out, run the script, choose whether you’re generating emails with or without redemption codes and then fire away!
You can now click through the list and start firing off emails like you’re your own spambot. Except you’re giving people legitimately cool things. And you’ll still be able to enjoy your afternoon.
If you’re interested in checking it out, you can download the source code on Github.
It’s like we have our own language…
11:22 PM
me: can i ask you a programming question?
Kerry: sure11:24 PM
me: so i have a stupid function
me: inside, there is a loop to create a long string based on certain (irrelevant) criteria
me: when the function is run by simply calling it in PHP (ie, by simply going: stupidFunction)
me: it outputs the string
me: now i want to save this string somehow, and it doesn’t seem to be working
me: should I simply be able to do something like:
me: $stupidText = stupidFunction(); ?11:26 PM
Kerry: what’s the return value of the string?
me: there is none, which is weird
me: i try to set one
me: and it screws everything up
Kerry: hmm
Kerry: well if there’s nothing being returned from the function, then simply outputting it won’t give $stupidText any value[…]
1:54 PM
me: i finally got stupidFunction to work last night!
me: it turns out that stupidFunction was creating a stupidArray inside of it
me: so basically $stupidText printed “Array” when I set it equal to stupidFunction
me: Once I did: $stupidText = stupidFunction[‘idiotDave’]; it all worked!
Kerry: woooo, nice work