WordPress 2.7 is slick
I just have to say that the newest version of WordPress is really, really slick. My favorite part is that now WordPress can upgrade itself and I don't have to rely on a plugin to automatically upgrade my wordpress pages for me.
At first it really disturbed me at how fast wordpress would push out updates, but now I really don't need to worry about it anymore. WordPress has now become it's own little platform. It's almost like SaaS (Software as a Service), but it's running locally on your server.
Now I just need to make some plugins.
Using overflow:auto for a tbody tag in IE 6.0
Guess what? It's not possible! in Opera 7.20, IE 5.5 or IE 6.0. Instead what happens is that it's treated like a regular table without the scrollbars. Also, the styling specified for the tbody is applied to every tr row. How lame.
Another reason why we all should just stop supporting IE 6.0.
Remove Anchors from a Url in Javascript
Here is something useful that I discovered in my programming for the Apparatus Complex. I needed to strip out the anchor portion of a link and leave the rest of the url intact. For example I wanted:
http://www.jelaniharris.com/blog/I-love-apple-pies#comments
To look like:
http://www.jelaniharris.com/blog/I-love-apple-pies
Here's the ideal way to do this with Javascript:
//Grab our current Url var url = window.location.toString(); //Remove anchor from url using the split url = url.split(“#”)[0];
It doesn't get any easier than that. What this code does is grab the URL from the current window, and then splits the string where a '#' is. Whether or not if the '#' exists in the string, it'll truncates the string up to the '#' or return the whole url.
Thanks to Jonathan Rochkind in the comments for this simpler version.
JQuery is the best javascript library out there
I officially declare JQuery to be the best javascript library out there. So much documentation, so many plugins, so many interesting things you can DO with that library. I just lost 7-8 hours, implementing a prototype of a feature for my discussion site, Apparatus Complex. In particular it's a meta-game that I'm developing so that users can compete with each other in a role-playing game while they wait for the site to update itself with content from other people.
So I had a crazy idea of using jquery and ajax to let people drag and drop equipment into slots, and then dynamically update what that piece of equipment would do to their statistics. Doing this in flash is really easy, I first got the drag and drop implemented (so easy with the Jquery UI), then I set the restrictions on which column each orb could belong in, and then I added the automatic update of the statistics just moments later. It was simply brilliant and it was pretty darn efficient. If you want to play around with this, it's located right here. The equipment orbs are generated randomly and so are the names.
By the way, MooTools and Prototype and Scriptalicious are okay as well. I'm just really impressed with JQuery right now.
Adding a delay to JQuery Functions
Recently I was working on a few functions that I didn't want to have activated immediately after hovered over a div. I neededthe functions to activate after a half a second of hovering by the user. To do this I created this this piece of code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | var display_timeout = 0; $(".orb_space").hover(function () { if(display_timeout != 0) { clearTimeout(display_timeout); } // save a reference to 'this' so we can use it in timeout function var this_element = this; display_timeout = setTimeout(function() { display_timeout = 0; // perform things with this_element here buy referencing it like $(this_element) if (!$(this_element).hasClass('magic')) { performRollinMagic(); } }, 500); }, function () { if(display_timeout != 0) { clearTimeout(display_timeout); } performRolloutStuff(); } ); |
Let's go through line by line to see what's happening here.
Lines 2: The JQuery hover function has two parameters. The first parameter is for the function to call when the user hovers onto the element, and the second one is for when the user hovers out. Lines 4-16 consist of the first function and lines 19-24 consist of the second.
Lines 4-6: So if we happen to flash our mouse over the element very fast twice, this will make sure that we only have one timeout function happening.
Line 9: When we in the setTimeout function we need to remember a reference to our current element so that we don't have to do some tricky DOM navigation to get the hover activated element with the setTimeout event. It's just easier to just make a variable to remember the element.
Lines 11-15: First we reset the display_timeout variable, and then we can perform our necessary hover actions in this setTimeout function. The 500 indicates that we want this function to occur after 500ms.
Lines 20-23: This looks very familiar doesn't it? It's the same thing from lines 4-6. This is so that if the user rolls out of the hover element, the timer countdown will immediately stop and the hoverin functions will not occur.
Old domain, new language
So I've been the proud owner of a new website that I was surprised to get: http://crimsonize.com. I've actually had it for awhile and nothing is there except an outdated version of WordPress, and a blank hello world page. I'm surprised that it hasn't been spammed (or hacked) to hell now. But now I need to do something with it.
I was considering making it a personal art portfolio, but now I'm leaning towards making it an art community where people share and critique each other's artwork. The only thing I'm concerned with is that I don't want people stealing art from deviantArt and claiming them as their own and having people complain to me about it. It's just one of those things I sorta don't want to deal with, and that I know I'm going to deal with when Apparatus Complex gets popular in the future - when it's complete.
Of course before I actually go through with this community website I have to look at all of the "competition" and see what they do right and what they do wrong and then capitalize on those issues. That's business and research I suppose. Having facts and history and repeating it doesn't guarantee that a site will be popular.
Also, I do plan on creating this website in a new language. I've heard a lot of good things about Ruby on Rails (and not-so good things). I also just found out that my webhost, Site5, completely supports rails so there's no reason now why I shouldn't be learning this popular and new language.
The best way that I learn a new language is to have a project - or a goal - in mind so that I can visualize what my goal is and what I take the steps I need to do to get there. I'm not really one of those programmers that can just do all of the examples in a book and claim that I know the language. I have to get really deep into the planning of the project, and notice the parallels between the new language I'm learning and the old languages I already know. Like just skimming through some sample code, I notice that the way Ruby is structured it looks like Python with Java sprinkles. Or maybe, more like Java Flakes cereal with Ruby marshmallows.
(That actually sounds kinda delicious. I'm in the mood for Lucky Charms now.)
They say that once you learn/master one programming language, all of the other languages you want to learn get easier. I think that's 100% true.
Middleware is your friend
There's nothing wrong with reinventing the wheel. In fact, sometimes that's the best way to learn how something works. But if you just want to get something done, middleware is your best answer. Here is some that I personally recommend.
Blogging Software
WordPress - With thousands of plugins and full customization, why would you install anything else? Perhaps if you're the kind of person that sits around wearing black turtle necks and hates something because it's popular. But you're not one of those kind of people? Right? Expression Engine isn't bad either - but you pay for that kind of quality.
3d Engines
Ogre for C++, Python, and C#. A great 3d engine that my friend and I are using to create our games. Ogre has a great community, with a very helpful wiki to get newbies started. However, some of it assumes that you know a little bit about 3d graphics before the intermediate ones seem to be truly helpful.
First Post!
Well, this is the start to my blog. Hopefully I'll post here often, but hopefully with something useful each time. I just don't want to have one of those blogs where you just post because you haven't posted in awhile. That always leads to apologizing at the beginning of every new post you make.
So, I'm just not going to apologize. I'll post when I feel like it.
