Archive for October, 2007

Oct 15 2007

More jQuery

Published by under Tech

Ok, so I did some more playing around with jQuery. I built on to what I had before. One of the other things I wanted to do was to get the categories on the left to expand and collapse similar to the demo that John Resig, the creator of jQuery, had demonstrated in this tutorial.
In that tutorial, John used a definition list to build what he called an accordion menu. My menus were build using an unordered list with headings and sub-unordered lists. I didn’t create this theme, I downloaded it so I had little control over how that was done. Needless to say, I needed to do some modifications to the code.
The original code was:

$("dt a").click(function(){
return false;

One of the first things I would like to point out, is the use of the $(document).ready() function. Since this isn’t a core part of javascript, it wasn’t something I was familiar with. Essentially what it does, is run the function that is defined once the DOM is loaded and is able to be manipulated by the function. This removes the need to use a type syntax that I used in my previous example. That’s what I get for trying to jump ahead and not read some of the tips the site gave for learning jQuery. I have since switched to using the preferred $(document).ready() method.

But let’s get back to what I want to do (and try and get it right this time). As you can see, it does a few things that either wouldn’t work for my situation, or are undesirable for me. First off, I wanted all my items hidden from the get go. The first line of code with the $(“dd:not(:first)”).hide(); is using the exclude selector to hide all but the first element. This was one of the things I didn’t want, but that was easy to fix. Just remove the exclude selector.
After that, he assigned the onclick event to all the elements. This had one characteristic that I didn’t want which is if you clicked a visible element, it would collapse that element and then show it again. So it was another situation I needed to work around.

Also, since I wasn’t using the definition list that the example was, I still needed to find a selector that would work for me. The code I implemented was:

$("#sidebar > ul > li").children().not('h2').hide();
$("#sidebar > ul > li").children('h2').click(function() {
if ( $(this).parent().children(':visible').not('h2').length ) {
$("#sidebar > ul > li").children().not('h2').slideUp("slow");
} else {
$("#sidebar > ul > li").children().not('h2').slideUp("slow");
return false;

I ended up using the css style relationship selector. The one major element I could work from, was a div that held the menu and had the id of sidebar. The first level child of that was an unordered list of each menu category. That gets me to the “#sidebar > ul”. Then, of course, I needed it to apply to each item in the list, so that brings the next ” > li”. The one complicated item now was that the first element had the label as a heading2 but the content was just in a paragraph tag. All the other items had a sub unordered list. At first I wasn’t using the child element select “>” and it made all of my list items disappear, but worked for everything else. Then I needed to rule out “h2″ as my category label but keep it ambiguous as to the content item. That brought me to $(“#sidebar > ul > li”).children().not(‘h2′).hide(); which would hide all children who weren’t h2, my headings.

This made selecting my onclick event elements easy since I just needed to get all the “h2″ children via $(“#sidebar > ul > li”).children(‘h2′).click(function() {. The next line of if ( $(this).parent().children(‘:visible’).not(‘h2′).length ) { fixes one of my issues with the original code. That being the problem of a visible item closing then opening when clicked. I needed the if statement to check to see if the current visible item was the one that was clicked. If so, it would just close. Otherwise it would close the visible item and open the clicked item.

At the end, I decided to make one more fix which I didn’t put in the code above. One of the other powerful features of jQuery, is the power to chain selectors, events and css modifications together. So after adding in the onclick event to all the items, I had it change the css of it as well to:

}).css('cursor', 'pointer');

A small item, but sometimes it’s those small details that make it work. I was worried people wouldn’t be able to identify that the categories are clickable. This was my fix.

I’m really having fun with jQuery and it’s one of the few things that I can see how it would make almost every web project I work on easier and better. Count on there being more posts dealing with it.


7 responses so far

Oct 15 2007

Another New Toy: jQuery

Published by under Tech

There have been a lot of new and interesting things for me to play around with this year with web development. I started playing around with yet another one called jQuery. It’s a javascript library with the goal in mind to make interaction with the web pages simpler. It definitely seems to have achieved it’s goal. It’s kind of like the Photoshop of javascript libraries. Any one who is really proficient with photoshop will tell you that the real power with it is it’s selection tools despite all the wizz-bang plugins that so many of the users find impressive. Same thing goes for jquery. While most of the articles I’ve read on it seem to concentrate on the cool animation features, it’s the innovative selection and event tools that seem to make it such a powerful tool and also makes those cool animation features possible.

My goal to test it out was something simple, but functional for me. For a while, I’ve lamented my laziness when it came to dealing with external links. I should have had them all opening into separate windows so I didn’t lose people and make it difficult to follow the links I post. I had thought some day that I would come across a word press plugin to help, but when I saw the features that jquery boasted, I thought this might be good task for it.

It didn’t disappoint. A mere 15 minutes of playing around with it in a greasemonkey environment and I had it working.

I didn’t want to add the library to my template directory just yet (here again, mostly due to laziness), so I cheated and borrowed the script from the site that hosts it. Fortunately it’s hosted on google code, so they can afford any measly amount of bandwidth my site will toss it’s way.

I needed to add the jquery script library:

<script src=""></script>

Once I had the code in there, it was just 1 line I needed to add to do everything I wanted:

function pageInit()
$("a").not("[href*='']").attr("target", "_blank");

And to run it:
<body onload="pageInit();">

What the one line does is it selects all the anchor tags used for the links with $(“a”) and then, since I didn’t want links that link to my own domain to open in a new tab, I had it omit those with the not selector not(“[href*='']“). It uses a match designated with the * to remove any matches of that expression from the first selector’s result set. Then once I have all the elements at that point, I set the attribute on all of them with the attr() function and tell it to set target=”_blank” to open in a new window or tab. Pretty awesome for just one line.

The even more awesome thing it, I could have just done this for certain portions of my blog if I wanted to. If I just wanted it to work from my blog posts, I could have wrote:

$("div.content a").not("[href*='']").attr("target", "_blank");

So that only the anchor tags inside the content div that don’t link to my site would be affected. The power of selectors. Sometimes it’s the power of the simple tools that make the application, or in this case the library, an effective tool. I think I’m gonna have a lot of fun with this one.


No responses yet

Oct 13 2007

Poker Update: Short Session

Published by under Poker

I was telling Zooks the other day, that playing at Cake Poker almost feels like a crime against the mentally handicapped. The play I’ve seen has been horrible and I’ve been getting paid of in some of the most ridiculous situations. That isn’t always good as some times there are tough calling spots and it’s difficult to not fall into the trap of becoming a calling station.

Here are a few hands from a short session today.

Hand 1:
UTG Me: (K♦ J♦) raised to $3.50
4 fold
BB calls
Flop A♦ Q♣ J♠
BB checks
I bet $5 (kind of a smallish bet, but from what I can at cake, if they are gonna call, then any bet from half the pot to pot size, doesn’t really matter much)
BB calls
Turn 6♣
River 6♣
check (I’ve learned I have little value here and even less fold equity, so I expect to see his A4 or QT or something)
BB shows 4♠ T♠
Um, ok – I guess I missed a value bet on the turn.

Hand 2:
2 fold
CO calls $1 (same villain as previous hand and has a stack of $18)
Button Me (K♦ Q♦) raises to $4.50 – I pretty much ignored his limp figuring a limp was as good as a fold for any normal person and my hand was way ahead of any limping range
Blinds fold
CO calls (obviously)
Flop: 9♠ J♠ 9♥
check – he doesn’t have much behind and I figure I had little fold equity to ANY draw so I checked to see another card
Turn: T♠
CO pushes for $13.50
I instacall
CO turns over 5♣ T♣
River was a non-important 7♥

Hand 3:
(Different table, same donktacular play)
UTG limps
Button Folds
SB calls
I in the BB checks with 9♠ 9♦
I thought about raising, but I thought it really just meant playing a big pot out of position against half the table
Flop: 6♦ T♠ 9♣
SB checks
I bet $3
CO calls
SB folds
Turn: T♥
I check hoping he has a ten
CO bets $6
I raise to $30
CO minraises to $54 – yep, has a ten, I just hope it’s not T6 which is a possibility
I push for $124
CO calls
CO shows T♦ K♦
River: J♣

So 20 minutes, 50 hands and I’m up $170. Not a bad small session. There was also another interesting hand that I didn’t get the HH for that was me getting stubborn on my first hand at the table with KQ when I got raised on a king high flop, checked turn when the flush and straight hit, then call a pot sized bet on the river to against his 3rd pair and busted gutshot.

As for the sessions size, I’ve been playing a lot of small sessions just when I have 15 or 20 minutes lately instead of waiting until I have 2 hours to sit down and play a real session. I just got epass working, and I really just need to get in as many hands as I can to clear the initial deposit bonus at Cake. Every little bit helps. I’m just hoping I get a few more sessions like that one and I should be up to playing the 200′s in no time. That will help speed up my bonus clearing as well.

That session also helped take the sting out of my home game last night. I just couldn’t hit a hand and in the first 4 hours, the 1 big pot I played was one where I made a hero call with K7 on a board of A743J and ended up chopping the hand. How the fuck does he have K7 there too? Sigh. Frustrating. I did end up doubling up after the 4th hour when my first real hand of aces got paid off by third pair and a gutshot (yes, same guy as the other hand). All in all I ended down $7 which wasn’t bad for as card dead as I was, but I was really thinking maybe I was rusty. After thinking of the hands I had though, it really was a case where the deck just looked the other way from me.


5 responses so far

Oct 12 2007

Extending the Web

Published by under Tech

Several years ago, I worked at a support call center doing training for the technicians. I was the Mac trainer (surprising, isn’t it). I was tasked with trying to keep all the support people who had to support Macs reasonably capable of dealing with that platform. It was a difficult chore especially considering that some of the groups had little exposure to the Mac and had infrequent issues concerning it.
I was also involved with the internal web development that we had in place and I made a legitimate and honest attempt at trying to simulate the mac interface on a web page. I spent weeks (in duration, not development time) to put together something that wasn’t exactly a good replacement for the real thing, but it got some of the techs through some interface questions.
After that experience, I gave up on considering representing an OS on the web. Over the last few years I would occasionally think back on the experience when some one would send me some flash joke that would try and trick the user that their windows was being uninstalled in favor of a Mac OS and the like, but hadn’t thought of trying to build an actual interface. Yesterday, though, I came across the single most impressive thing I’ve seen in web development since the last single most impressive thing I had seen. To be fair to both Flex, I wasn’t really impressed with Flex itself, but that Adobe decided to offer the open source community to be able to build these things without having to buy software and having support from Adobe. I thought that was a very forward thinking decision on their part. And not an easy one for the, I’m sure.
Then I saw the drool worthy, impressive feat that the group at Ext JS accomplished when they provided a demo showcasing some of the features of their upcoming 2.0 release of their library. This virtual desktop representation finally puts a realistic desktop environment into reach. Even if you aren’t into technology, it is still impressive what they accomplished. Not to mention that it isn’t cumbersome or difficult to use. It’s feels light and responsive which is really impressive for something still in beta.
I don’t want to misrepresent it as being a finished product. There are still some features that would be nice to have to make the user experience a little closer to home as far as what they are used to, but this is leagues ahead of any other attempt I’ve seen using just technologies supported by the browser on it’s own. No plugins required.
You can often see posts from Asa Dotzler about how the internet is going to be the next big user platform and that the browser will be the only required program on your computer to replace our current operating systems (which ever that may be). This is the first time where I see that as a definite possibility. Great strides have been made recently by groups like Ext JS to make the internet more of a viable development platform for applications that are actual viable replacements for desktop applications. This is bridge that gap where web portals become more like distrobutions are in the linux world where one site gives you an interface to use applications based on other sites and really just give you the easy to use interface to access them. No more googling to find an online spreadsheet program.
What’s the next step? Some one needs to take this implementation and incorporate a mashup with google documents so the desktop feels real. That will be my next “single most impressive” moment in web development.


One response so far

Oct 09 2007


Published by under Humor,News

It’s the driving force of news media everywhere to conjure up ratings. (even if it’s fictional news)

Missing Girl Probably Raped


No responses yet

Oct 06 2007

Someone Please Explain This to Me

Published by under Poker

I’ve been reading Alex Jacob’s blog and while it isn’t the most interesting poker blog out there and isn’t the most up to date, I think Alex is a smart and interesting player. And since I’m stuck in bumfuck, ND for the weekend, I thought I was catch up on some of my reading.

This probably has something to do with the fact that I’m not a tourney player and just don’t understand situations like this, or there is more to the story that happened during the live hand, but I just don’t get this hand that was posted during the coverage of the USPC (one of my favorite tournaments to watch on TV, BTW).

Tmay loses one of those pots that you talk about for weeks…

How often do you take the cautious route when you hold the second nuts in a HU pot that you only lose to a hand that would have 2 outed you on the turn? This is one of those spots that I WILL go broke and chalk the hand up to a cooler.

About the only situation I can foresee not taking a stab on the end is if you think this is a spot where only a better hand calls your raise so their isn’t any equity based reason to make the raise on the river. I can’t think of any other reasonable situation I would assume that my opponent has a hand that I don’t at least chop with. I’m not gonna look for skeletons in the closet and assume some one has the immortal nuts when I’m in a hand with them.

I still think there has to be more to this that the story lets on. I just don’t see some one doing that in a normal situation. Feel free to comment on what you think.


2 responses so far

« Prev - Next »