sas the investigative hedgehog (theaeblackthorn) wrote in lj_nifty,

PHP Weather Layout Changer

Hi all!

I'd seen the rotating header image code before and it got me thinking what else you could do with a nice bit of php and livejournal.

So, I've made a PHP page that returns a different CSS depending on the weather in your current area!

It uses a Yahoo weather feed to figure out the current weather and picks from a list of stylesheets you can provide it with.

Well, I thought I'd share it with everyone!

instructions and code at my journal

I'm happy to answer any questions.
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 17 comments

notagod

September 26 2009, 20:11:14 UTC 5 years ago

(Jokingly) Dare we trust someone who can't close his quotes?

notagod

September 26 2009, 20:12:20 UTC 5 years ago

Dare we trust someone who assumes genders? *laughs*

andy

September 26 2009, 20:44:45 UTC 5 years ago

There's maybe a language barrier involved, but I didn't spot any gender assumptions in there. The choosing of if statements over switch or associative array still made me smile though.

THAT SAID, I think that this idea is neat enough not to care about implementation details like that. I believe in the good intent of the post author, and I wouldn't want him/her to be disappointed by picking in comments like this.

notagod

September 26 2009, 20:49:24 UTC 5 years ago

I was being self-deprecating on the second. See my choice of "he", then have a look at the OP's journal.

andy

September 26 2009, 20:51:39 UTC 5 years ago

Ah, got it now. Thanks for clarifying! :D

theaeblackthorn

September 26 2009, 20:45:56 UTC 5 years ago

It's what we get for breaking our keyboard and resorting to our backup one. Fear not, the code was typed up before!

And more importantly, it's currently running my lj's layout. :)

notagod

September 26 2009, 20:48:32 UTC 5 years ago

*nods* definately very nice work :) I have no host to run it myself, but from a quick look I was quite impressed :)

theaeblackthorn

September 26 2009, 20:50:51 UTC 5 years ago

A friend kindly let me host it on hers, I'll agree my execution may not be the most elegant, but it spooks people who visit my lj well enough, so I'm happy :)

notagod

September 26 2009, 20:56:56 UTC 5 years ago

Actually I disagree. I could sight read it, and I don't do php. It's commented enough to grok the ideas of the routine, and it's instantly sight readable. Two very key features in good code. Means that later maintenance is easy and achievable, and that's something that you learn from experience is a really really really good thing :) Smart's no good if you can't understand it in 6 mths time.

theaeblackthorn

September 26 2009, 21:06:06 UTC 5 years ago

Indeed, good documentation is vital for later code maintenance. The amount of times recently I've had bugs for areas and found the code to just be unreadable is ridiculous.

Generally I work with Java, not PHP hence my PHP isn't the best, it's more a hobby than a job :)

lanitha

September 26 2009, 20:14:27 UTC 5 years ago

Fun idea!

theaeblackthorn

September 26 2009, 20:46:05 UTC 5 years ago

Thanks!

foxfirefey

September 26 2009, 20:43:35 UTC 5 years ago

Cute!

theaeblackthorn

September 26 2009, 20:46:10 UTC 5 years ago

Thanks!

janeway216

September 26 2009, 21:13:52 UTC 5 years ago

That's nicely done! I've been using something kind of like that on my journal for a couple years now to print the current temperature in my journal sidebar (like so: ) but extending it all the way out to the layout CSS is a neat trick and one I hadn't thought of.

The only quibble I'd have is using a switch statement in place of the if statements, but you've explained your reasons for using them elsewhere and that's a personal preference anyway. ;-) Very cool!

astatine210

September 26 2009, 22:38:19 UTC 5 years ago

I just open the curtains :)

kellzilla

September 27 2009, 04:58:39 UTC 5 years ago

I can't open your curtains. :)

Therefore, using the OP as an example, I can "look out her curtains" by visiting her journal. :)