my life as drawn by phdcomics.com |
The problem at least for me, is that it I'm well-isolated from the outside world, so that it could just as easily 9° or 90° outside, and I wouldn't know. I've felt apprehension to wander upstairs, only to find that, once I got there, it wasn't all that bad.
With a previous printer, I would write the current conditions to the front-panel LCD, because Perl, but we've moved from HP to Xerox, and I no longer have that ability. I now have it tell the time and temp at the top and bottom of the hour, to keep from being so deep in the zone that I think it's lunchtime when it's really quittin' time. I also had code to generate notify balloons, but a recent switch from Ubuntu to Debian made that unusable.
I've been playing with NoSQL databases and have found that I spend most of my time with MongoDB, but once I started thinking about the weather problem — I need it to be available to any of my n terminals, I don't need structure — I decided that Redis was the way to go.
Each NoSQL database works in a different way. MongoDB works as a Document Store, holding a piece of structured data until you call it back. I have code to record daily status updates and send it to bosses where each day holds an array full of objects holding a timestamp and status report, and at 6pm, if the day's array holds data, it formats that data and sends the mail. This is more structure than I really need in this context.
What I really need is essentially a hash table that I can access from many different programs. If it falls down, that's fine; I don't need to remember what the temperature was at 4am, I just need to know what it is now, or within the last 10 minutes. Redis works like that, and (unless you have it commit to disc), it's only in memory, so fast. (I think; I've only played with Redis, not put production data into it.) I think this feature would be good in, for example, Raspberry Pi uses, where excessive access could prematurely kill your SD card.
Anyway, here's my code to store the temperature, to pull it back out, and a replacement $PS1 to show you how to add it to your prompt. It backends to forecast.io, my most recent go-to for weather information. The API is very useful and easy to use. (I don't put "Powered by Forecast" in my prompt but I do put it in the program that uses notify-osd and Pushover.) Use it in good weather.
No comments:
Post a Comment