Linkify text links on page load using JQuery:
Alter the regex to allow other hosts (Corrup posted this for me previously when i was banned, thanks corrup).
One Liner'ing Stuff
messing around with logic, one liner'd:
SEO'ing a string
I see people str_replace'ing special characters and such to turn 'abc def (2005)' into 'abc-def-2005', but there's an easier way:
P.S thanks guys for posting for me while I was banned.
Code:
$(function() {
var sexyregex = /^http:\/\/(hotfile\.com|rapidshare\.com|megaupload\.com)\/[\S]+$/;
$('body *').contents().filter(function() {
return this.nodeType == 3 &&
$(this).text().trim() !== '' &&
$(this).text().trim().match(sexyregex);
}).each(function() {
$(this).replaceWith('<a href="' +
$(this).text().trim() +
'" target="_blank" rel="bitches_dont_know_bout_my_regex">' +
$(this).text().trim() +
'</a>');
});
});
One Liner'ing Stuff
Code:
if($x == 'abc') {
somefunc();
return false;
}
Code:
if($x == 'abc') return !(somefunc() || true);
SEO'ing a string
I see people str_replace'ing special characters and such to turn 'abc def (2005)' into 'abc-def-2005', but there's an easier way:
Code:
function jmzseo($s, $b='-') {
return preg_replace('#[\W]+#', $b, $s);
}
// use as such: jmzseo('abc def (2003)') to return 'abc-def-2003'
// also can change seperator
// jmzseo('abc def (2003)', '+') = 'abc+def+2003'
P.S thanks guys for posting for me while I was banned.