Error
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.

title

jQuery Hover Swap Text
Monday, 12 December 2011 15:19

Things have been busy! I’m working on a new book and site and having a blast. I’ll share more on that later, but for now I just want to get back into posting at Perishable Press. To kick it into gear, here is one of the jQuery snippets I’m using at the new book site.

jQuery Hover Swap Text

There is probably a better way to do this, but I needed a way to swap link text with the title attribute on hover. Nothing fancy, and I thought for sure there would be an easier/existing way of doing this with jQuery, but didn’t see anything so came up with this lil’ snippet:

// jQuery hover swap text @ http://perishablepress.com/jquery-hover-swap-text/ 
function xycss_swap_text(){
	$('a').hover(function(){
		var title = $(this).attr('title');
		var text  = $(this).text();
		$(this).text(title).attr('rel', text).removeAttr('title').wrapInner('<span />');

	},function(){
		var title = $(this).text();
		var text  = $(this).attr('rel');
		$(this).text(text).attr('title', title);
	});
}
$(document).ready(function(){
	xycss_swap_text();
});

Just drop into your JavaScript file and edit the $('a') selector with your choice. Going thru, this is just a jQuery hover function that swaps the contents of the title attribute with the anchor text. I also wrap the hover text with a <span> (for styling purposes), but you can yank that out of there if it’s not needed.

Update:

Bryan Watson extends this snippet into more of a plugin format:

(function($){

    // Swap text with title attribute
    $.fn.swapTitleAttr = function() {
    
        var title = this.attr('title');
        var text  = this.text(); 
        
        $(this).wrapInner('<span />');
        
        $(this).hover(function(){
            $(this).text(title).attr('rel', text).removeAttr('title');
        },function(){
            $(this).text(text).attr('title', title).removeAttr('rel');
        });
    };
    
})(jQuery);

$(document).ready(function(){
    $('a').swapTitleAttr();
});

As Bryan explains, with this version “the vars are outside of the hover function (and don’t need to be redefined). Plus, it makes the function reusable for any selector with a title attribute.”

Better way?

Drop some hints if you know an easier way of doing this — I’m sure there’s a better way :)

© 2011 Perishable Press

Read more: http://perishablepress.com/jquery-hover-swap-text/

 
Extract artist and title from a song title string
Tuesday, 21 June 2011 10:25
Extract the artist and the title of the song from a string formatted as: ARTIST - TITLE.EXT
This code strips the extension, splits the string, trims each part and capitalize it correctly (fixed pythons string.title() bug for handling apostrophes)


#filename = "rihanna - please don't stop the music.pdf"
artist, title = [re.sub("([a-zA-Z])'([A-Z])", lambda m: m.group(1) + "'" + m.group(2).lower(), t.strip().title()) for t in filename[:filename.rfind('.')].split('-')]

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/tdLjec51WnA/13281

 
100 Years of Eye-Popping Title Sequence Evolution [Video]
Wednesday, 16 March 2011 20:40
If you've got even the slightest bit of cinephile in you, you need to watch this whirlwind tour of some of the most creative title sequences ever. Ian Albinson's "Art of the Title" debuted recently at SXSW; put it on top of the pile of reasons you wish you'd made it out there this year. [Art of the Title via b3ta via The High Definite] More »


Read more: http://feeds.gawker.com/~r/gizmodo/full/~3/m177t20x9NQ/100-years-of-eye+popping-title-sequence-evolution

 
Creating AVI Video from mp3 File
Sunday, 07 November 2010 16:00
This script is useful for create an AVI video from a mp3 file to upload to Youtube.
A image will be placed in a black background with mp3 title in white
Author: Eduardo Mucelli R. Oliveira
Based on ideas and codes from http://ubuntuforums.org/archive/index.php/t-1244112.html and http://www.crimulus.com/2010/01/21/linux-bash-script-convert-mp3-to-avi-with-static-image-command-line


#!/bin/bash
FFMPEG=`which ffmpeg`
FPS=1 # for a youtube video from a mp3, it is enough

if [ "$FFMPEG" = "" ] ; then
echo "Please install ffmpeg.";
exit 0;
fi
if [ $# != 2 ] ; then
echo "Usage: $0 ";
exit 0;
fi
if [ ! -f $1 ] ; then
echo "Source mp3 '$2' not found.";
exit 0;
fi
if [ -f $2 ] ; then
echo "Output file '$2' exists. Overwrite? (y/n)";
read CONFIRM
if [ "$CONFIRM" == "y" ] ; then
echo "Overwriting '$2'"
else
if [ "$CONFIRM" == "Y" ] ; then
echo "Overwriting '$2'"
else
echo "Operation canceled.";
exit 0;
fi
fi
fi

TITLE=`$FFMPEG -i $1 2>&1 | grep TIT2 | cut -d: -f 2 | tr -d "'"` # get the title and remove "'" chars
IMAGE=/tmp/$RANDOM.gif
convert -size 1024x240 xc:black -fill white -draw "gravity Center text 0,0 '$TITLE'" $IMAGE # generate a black-background image with mp3 title in white
TIME=`$FFMPEG -i $1 2>&1 | grep Duration | cut -f1 -d, | cut -f2,3,4,5 -d:`
$FFMPEG -r $FPS -loop_input -i $IMAGE -i $1 -acodec copy -y -t $TIME $2
rm $IMAGE

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/oLENS_5pH8M/12593

 
Subscribe, push
Wednesday, 11 August 2010 00:09
erektile dysfunktionerektile dysfunktionerektile dysfunktion therapie helden der liebelevitra deutschland

function init() {
display = document.getElementById('content');
display.innerHTML = 'Waiting for posts... (they come once a minute)';
var feed = new google.feeds.push.Feed('http://fastpshb.appspot.com/feed/1/fastpshb');
feed.subscribe(displayEntry);
}

google.setOnLoadCallback(init);

function displayEntry(response) {
var feed = response.feed;
var entries = feed.entries;
entries = entries.reverse();
for (var i = 0; i < entries.length; i++) {
var entry = entries[i];
var title = entry.title;
var content = entry.contentSnippet;
var link = entry.link;
var container = document.createElement('div');
var anchor = document.createElement('a');
anchor.innerHTML = title;
anchor.href = link;
container.appendChild(anchor);
container.appendChild(document.createElement('br'));
var contentParagraph = document.createElement('p');
contentParagraph.innerHTML = content;
container.appendChild(contentParagraph);
container.appendChild(document.createElement('br'));
container.appendChild(document.createElement('br'));
display.insertBefore(container, display.firstChild);
}
}

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/54LVd3slVvM/12025

 


Taxonomy by Zaragoza Online