Tuesday, June 15, 2010

Rip Javascript in PHP with a str_replace()

So yesterday, I gave a nod to David Baker's preg_match across multiple lines. And now, the reason I was looking for something along that route, tada!



function rip_java($content) {
$p = '|(\<script.+?\>.+?\</script\>)|ms';
preg_match_all($p, $content, $matches);
if ($matches[0]) {
foreach ($matches[0] as $v) {
$gp = '|http://drincruz\.blogspot\.com|i';
preg_match($gp, $v, $gpmatches);
if (!$gpmatches) {
$content = str_replace($v, '', $content);
}
}
}
return $content;
}


Javascript is very useful in this revision of the internet. However, if you allow other people's javascript on your site, then well, that's an entire whole different security issue. So what we wanted to do at work was only allow certain javascript to run on our sites; and that javascript being the code that we write.

This was written in PHP because we're using it with WordPress' content_save_pre filter.

Cheers!

Monday, June 14, 2010

preg_match across multiple lines

preg_match across multiple lines

I'm working on a plugin that required a multiple-line REGEX match. For whatever reason, my mind went blank even though I've done it before. Anyhow, here's a nice write-up by David Baker.

Cheers!

Wednesday, June 2, 2010

Exclude Directories in Bash Find | practical web development & design. cincinnati, oh

Exclude Directories in Bash Find | practical web development & design. cincinnati, oh

Just a quick blurb to thank tcmacdonald's blog for the help with this bash find command snippet:

find . -type f -not -path "*svn*" -exec chmod 644 '{}' \;


To be specific, I'm using `find` in a for loop to get all directories but I didn't want the results for the root directory (./).

So my snippet now looks like:

for f in `find . -maxdepth 1 -not -path '.' -type d`; do
...


And now I don't see the results for ./ listed! Thank you! Cheers!

Thursday, May 20, 2010

Google TV Is Official: The Web And Pay-TV Have Finally Clashed - HotHardware

Google TV Is Official: The Web And Pay-TV Have Finally Clashed - HotHardware

Alas the long awaited big news from the 2nd day of Google's I/O: Google TV.

We already abandoned cable, satellite, etc., television and only receive the free OTA (over-the-air) channels. To supplement with OTA, we also watch a lot of shows online via my laptop connected to the TV. But now, Google innovates the two?! Interesting. At this point, I'd still rather just build my own HTPC, but this makes it a lot easier for the less tech-savvy TV watcher.

Let's see how things go with Google TV. Cheers!

Thursday, May 6, 2010

Lego Robot Solves a Rubik's Cube in 25 Seconds Using Droid Phone | Inhabitat - Green Design Will Save the World

Lego Robot Solves a Rubik's Cube in 25 Seconds Using Droid Phone | Inhabitat - Green Design Will Save the World

You know when people say, "you have to see it to believe it"? Well, this was one of the moments for me. I read the article and was amazed at first, but the pictures look deceiving. They look fun, playful, perhaps a bit jovial, so I didn't take it seriously.

Until I saw the video that is! Wow! I mean, really WOW!

Kudos! Cheers!

Wednesday, May 5, 2010

Google Rolls Out Flashified, Turbo-Charged Version of Chrome | ConceivablyTech

Google Rolls Out Flashified, Turbo-Charged Version of Chrome | ConceivablyTech

Heh...very interesting. So I have been just using the dev daily Chromium releases and May 4th's release seemed so unstable that I had to remove it and then just install the public beta.

It just so happens that I installed on a wonderful day. This release is so up-to-par and wonderful! I was wondering why it's flash was running so well (compared to the earlier betas).

Kudos guys!

Cheers!

Wednesday, March 3, 2010

MediaPost Publications Bloggers Now Eligible For Press Passes In NYC 03/03/2010

Wow, well would ya look at that! Bloggers now are eligible to obtain press passes in NYC!

MediaPost Publications Bloggers Now Eligible For Press Passes In NYC 03/03/2010

This is such a big win! Though, this might open the flood gates for any psycho with a blog. Well, they say otherwise, "Certainly you can't give credentials to everybody with a computer," but, how are they going to distinguish these legitimate bloggers? Interesting...