New Homepage Now Exists

Posted on 2nd April 2011 in Something Daily

The idea occurred to me recently that I wanted to have a place online that functioned both as a portal and hub for my other online presences (twitter, tumblr, this) and as a networking tool for me to direct people to via word of mouth so they could get a look at my resume and portfolio. So over approximately the last two weeks, I put in the work to register the domain and buy the hosting, moving this blog to my own host as well as moving the domain name threestegosaurusmoon.com to here. I also just sat down last weekend and decided to design the homepage, which was surprisingly easy in light of the fact that this was really my first experience with CSS. The design part was easy and fun; the process of implementing the design across multiple browsers was not either of those things. Once I had a design worked out nicely in Opera, I tested it in Firefox, Safari, Chrome, and….Inernet Explorer (don’t get me started). Basically, everything was a mess, since I didn’t know from experience what to avoid in the first implementation. But I had a five hour shift last night where I wasn’t doing much of anything, as well as access to a Windows laptop running IE9, so I had a great opportunity to iron out all the stupid horrible display bugs that it imposed upon my design, which worked more or less the same across all the other browsers I tested. Like I said, please don’t get me started on Internet Explorer.

Anyway, the nap I took yesterday before work enabled me to stay up until about 2:30 putting the finishing touches on emmettbutler.com, including the automatic emailing form and custom favicon and 404 pages. I also implemented a tagging system for the gallery of my work using (for the first time) object-oriented PHP, which is actually really awesome. Sometimes, when I don’t use OOP for a little while, I forget how awesome it is. But it is really useful. This is my first website, but I’m actually quite proud of it. And, in light of how easy it was to make (took me about a week without Dreamweaver or anything of the sort), I’m very open right now to the idea of doing freelance web design for people who need it. It’s exciting. So yeah, check out my new website. I like it.

Now I’m going to go buy that Four Loko skateboard deck and maybe some old computers, depending on the price. Bye!

PHP Howto: scrape an RSS feed

Posted on 29th March 2011 in Tutorials

Since I’m building my own homepage, I recently learned how to scrape an RSS feed in order to dynamically create content for a website. The idea is that I would have separate feeds from my twitter, tumblr, and this blog all in one place. The tumblr and twitter feeds are offered by those companies in the form of API calls, so using those two is very straightforward in both cases. When self-hosting a wordpress blog, though, as I do, there is no readymade option for a feed that one can just call and have ready to go. So I had to make my own.

An RSS feed is essentially just an XML markup document that browsers interpret and show you in some type of feed form. What I wanted to do with this document (which wordpress produces for me) is essentially the same as what the browser does with it when you click an RSS link – it parses the tags in the XML document and applies predefined visual styles to make the information accessible to humans.

PHP can perform this process quite simply, via the simplexml_load_file function, which provides a simple framework for parsing XML documents.


$feedUrl = 'http://emmettbutler.com/threestegosaurusmoon/?feed=rss2';
$ret = array();

// retrieve search results
if($xml = simplexml_load_file($feedUrl)) { //load xml file using simplexml
$result["item"] = $xml->xpath("/rss/channel/item"); //divide feed into array elements

foreach($result as $key => $attribute) {
$i=0;
foreach($attribute as $element) {
if($i < 3){
$ret[$i]['title'] = (string)$element->title; //assign the desired elements to array entries
$ret[$i]['timestamp'] = (string)$element->pubDate;
$ret[$i]['summary'] = (string)$element->description;
$ret[$i]['link'] = (string)$element->guid;
$i++;
}
}
}
}

After the initial call, this code examines each unit of the divided document and assigns the contents of certain tags to elements of the $ret array. For example, there is a line in each item of the feed that is denoted by the pubDate tag, which contains the date that a certain post was published. The line $ret[$i]['timestamp'] = (string)$element->pubDate; finds those tags and assigns their contents to the $ret array. Once this loop is complete, you’ll have an array full of all the pertinent data for your feed. You can loop through the array and print each element between the appropriate tags, style with a bit of CSS, and you have yourself a homemade and very professional-looking RSS feed widget on your website.

comments: 0 » tags: , , , , , , , ,

One does not simply walk into the internet

Posted on 23rd March 2011 in Something Daily

It may be a little bit easier than getting into Mordor, but it’s still a bit of a process to build up an internet presence. I’m starting the process of writing a personal website for myself, which should be a great experience. I just bought the web host, which means that in a few hours I won’t have to use my roommate’s hosting anymore – it’s already been a bit weird telling people the URL for Spaceratops and having it include “.ericsluyter.com/”. Something’s wrong with that, I feel like. Still, awesome of him to lend me the space while I was learning.

So as a result of me now having web hosting, this blog may start to behave strangely in the near future. I’m going to move it to my own host, which means I’ll then be able to edit CSS myself and use custom plugins (like a random button – I’ve really been wanting that). I’ll do my best to never let threestegosaurusmoon.com actually go down at any point, but it may still happen. If so, rest assured that very soon it will be back and probably better.

As for the personal website, you may be thinking “but Danger, you already have a personal website – it’s called Three Stegosaurus Moon, which I know because I visit every day and have read everything you’ve ever posted.” To that, I would say thank you, first of all, and secondly that this website on which you read presently only represents a part of what I’d like my web presence to be. Here, I can talk about whatever’s on my mind, update daily, do sloppily-written video game reviews and shameless plugs of my own work, whatever I want, basically. It’s kind of fun. The idea I have for this new one is that it will be slightly more serious/professional and less dynamic than this blog. This isn’t to say that I won’t give it a crazy 8-bit rainbow theme, which I will, don’t worry…it’s just that the content there will be probably more interesting to someone looking at it from a professional standpoint. Like I can put up my resume (which is extremely impressive (<sarcasm)), a little bio (not a sci-fi story that I wrote in 45 minutes), a big compendium of things I've created, and a list of links to everywhere that I am on the internet. You know, like my home base. I'm just beginning to consider the design, but I'd like to have something going on there by the end of the term. I think it'll end up being awesome.

If I start doing more visual art, I may also start a tumblr, because I like their default layout for showing gifs and images.

Get excited. Stuff is about to start going down. And play Spaceratops.

Starting to Build a Message Board

Posted on 6th March 2011 in Something Daily

It just occurred to me that life is too short to not write about whatever you want on your blog.

I’ve been teaching myself MySQL, PHP, HTML, and CSS over the last handful of days, originally starting with the W3Schools tutorial. That very quickly grew into the seed of an idea for an introductory project which, when it’s complete, should give me a command of the skills I need to have for the hackathon in April. So the idea is that I’m going to put together a message board, with 4chan as a template/inspiration. I want to have nice looking page layouts (not looking for anything horribly fancy, as I’ve never really used CSS in my life), as well as the functionality of viewing/starting/replying to comment threads and attaching images to comments. Eric gave me a subdirectory on his web host, so I’m using that to practice uploading files. It’s going well so far, I’ve figured out how to use a text file to store the information on submitter name, image, and comment content, and to display them in something vaguely resembling a thread format. The next step is to learn how to do that with MySQL databases instead of text files. That shouldn’t be too much of an issue (at least I hope not).

One other thing – this morning I downloaded Odd Future’s demo tape from their website and it’s some of the most evil rap I’ve ever heard, and the rhymes are so good. Also, Tyler the Creator just celebrated his 20th birthday today, and Earl Sweatshirt is 16. Check out OFWGKTA (this video is not safe for work or small children or anyone who doesn’t especially like profanity).