Translate

Archive for December, 2008

jQuery tag wrapping

Friday, December 19th, 2008

Many times you’ll be working on something in HTML that could be long and repetitive, and then for some reason you need to edit the entire thing to wrap each of the tags on some other tags, a common example would be to link many elements.

Take this example, there’s a bunch of photos, they’re all contained in divs that have a css class called “photos”, inside we just throw
a bunch of <img> tags, and all of a sudden our boss tells us he wans to have every image on that page linked to “http://domain.com/photos”. jQuery to the rescue, no need to wrap each <img> with <a href=”"> by hand, you can do it all in one line

So if the code looks like this:

       <div class="photos">
            <img src="http://domain.com/0670027481_m.jpg"/>
            <img src="http://domain.com/211161aa99_m.jpg"/>
            <img src="http://domain.com/173bb0cd6_m.jpg"/>
        </div>
        <div class="photos">
            <img src="http://domain.com/841fd90b5b_m.jpg"/>
            <img src="http://domain.com/52dda2cee5_m.jpg"/>
            <img src="http://domain.com/b569399599_m.jpg"/>
        </div>
        <div class="photos">
            <img src="http://domain.com/8806e863a4_m.jpg"/>
            <img src="http://domain.com/5e43aa95fe_m.jpg"/>
            <img src="http://domain.com/68a74a088c_m.jpg"/>
        </div>

        <div class="tshirt-photos">
            <img src="http://farm4.static.flickr.com/3149/3113619519_72ce82c545_m.jpg"/>
            <img src="http://farm4.static.flickr.com/3236/3105792155_99f2388869_m.jpg"/>
            <img src="http://farm3.static.flickr.com/2114/2372582266_765842fae9_m.jpg"/>
        </div>

With jQuery you can match all the <img> elements, and wrap them all with “<a href=”http://domain.com/photos”></a>” in a single line of code:

$(document).ready(function() { $(".photos img").wrap('<a href="http://domain.com/photos">') })

So to explain how it works, when the document is ready (when it’s finished loading) the function inside is called back, it will use the jQuery selector $(“.photos img”) to match all the <img> tags contained withing elements of css class “photos”, then it applies the wrap() function, which will wrap the matched elements with the given html tags.

About jQuery

jQuery is a lightweight JavaScript library that emphasizes interaction between JavaScript and HTML. It was released January 2006 at BarCamp NYC by John Resig.

Dual licensed under the MIT License and the GNU General Public License, jQuery is free and open source software.

jQuery contains the following features:

  • DOM element selections
  • DOM traversal and modification, (including support for CSS 1-3 and basic XPath)
  • Events
  • CSS manipulation
  • Effects and animations
  • Ajax
  • Extensibility
  • Utilities – such as browser version and the each function.
  • JavaScript Plugins

jQuery Documentation

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Recession on a country with lines for $5 coffee, really?

Monday, December 15th, 2008

Either the recession is a media stunt, or people don’t know the value of the money they got left.

Last week I traveled by car from Washington,DC to New York, and on every service station I stopped along the highway, it was pretty much impossible to get a starbucks coffee because the lines were ridiculously long.

I thought it was a Manhattan phenomenon that so much people would want to pay for expensive coffee, given that you can actually have really good coffee for $1 or less if you think about it.

Has the dollar lost so much value, or we no longer think about how much things are worth?

To put it in perspective, I often think about the cost of energy and all of the things you can do with a gallon of gas.

The most expensive gallon of gas I’ve seen so far in the United States has been about $5 and we were outraged. But seriously, we’re paying way more for coffee.

To get a gallon you’d need about 16 cups, let’s say each small cup of starbucks costs $3, that’s $48 a gallon. The average car holds up to 15 gallons, you’d have to pay about $720 to fill up the tank.

Coffee is a freaking renewable resource, it can grow on it’s own for all we know, why do we accept to pay so much for it?

Oil heats your home, Oil is used to make electricity so you can read this, Oil can transport you and your family with a lot of shit in the car for miles, it’s been extracted out of the earth, it’s been processed by super expensive technology, there’s shitload of R&D to find it, if it wasn’t for it, pretty much billions of people wouldn’t even exist, we couldn’t travel or transport goods, and best of all, it’s non renewable… why the hell is it so cheap? or is the right question, why is coffee so damn expensive?

Fashion, laws of reason don’t apply

If George Boole would enter Lord & Taylors, he’d come back 15 minutes later with an Ak47 after loosing his mind and shoot everyone in the store for being so stupid.

If I showed you this, how much would you say it’s worth, a black jacket and white shirt for a woman, that pretty much looks like an every day use garment

$50, or maybe even $150 for the whole thing (and I still think that’s expensive) right?

Think again…

$200 for the shirt, and $500 for the jacket, $700 fucking dollars! And that’s without shoes, skirt and jewelry, seriously women, what are you thinking? are you thinking?

And then I looked around me, and there was this herd of women lurking around the store, looking at all the clothes like if they were hunting for their prey, they had this twisted look in their eyes as they checked every piece of clothing.

And why? Why do they even there pricing a jacket for $500 (or more, I saw even more expensive ugly crap in there) Because I think that Fashion companies rely on the fact that there’s dumb ass people that have no clue on what to do with the money, and who have lost perspective of all the things they could be doing with the same amount of money, or who really don’t have a clue of basic aritmetics, or the “greather than” operator, and that a higher numbers on a price tag means more money?

Sometimes I really feel like saying Recession my ass, and I often wonder if all the people being layed off are just suffering the consequences of the irrational fear on investors, which has been manufactured by the media puppeteers, who sometimes decide to sell us Britney’s clubbing stunts and another day scare us with “the crisis”.

And Fucking Christmas, every year I see how much faker it gets. With so many layoffs the TV should be telling you to keep your money for food, and to just go and enjoy your family and plan on what to do next year. But that’s a whole different subject for another post.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Geek T-Shirt Collection #6 – Strands.com

Friday, December 12th, 2008

geektshirt-strands

Thanks to Kalong from Strands.com for sending this one.

About Strands

Strands, Inc. is a developer of social recommendation technologies founded in late 2003 by Dr. Francisco J. Martin.

Strands develops technologies to better understand people’s tastes and help them discover new things they will like. Strands has created a social recommendation engine that provides real-time recommendations of products and services through computers, mobile phones and other Internet-connected devices.

See the Previous T-Shirt
See the Next T-Shirt

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Best Rehabilitation Program for Prisoners

Friday, December 12th, 2008

Dancing!

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Most viral videos of 2008

Friday, December 12th, 2008

I just can’t help to share this with you all, a recap of the most viral videos of 2008.
The Beyonce “Put a ring on it” homages cracked me up.

As 2008 wraps up, it”s a great time to look back at this montage of the year”s funniest viral videos. It”s a great collection, though we think it”s missing a couple of our favorites including this clip of Mr. T rapping, this video of Quentin Tarantino”s Chocolate Rain remake, and of course our favorite, Lil” Bill O”Reilly.
Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

This is flying

Thursday, December 11th, 2008


wingsuit base jumping from doubleA on Vimeo.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)