Tuesday, October 28, 2008

Windows Media Player Skip to Next Song Hotkey

Occasionally when I've turned off my computer monitor I still have the Windows Media Player playing songs on a playlist and I want to skip to the next song. It's kind of annoying to have to turn on the monitor and mouse to the skip button to click it. I tired right-clicking on the skip button to see what the hotkey is, but it only shows "Fast Foward CTRL-SHIFT-F". Well CTRL-SHIFT-F does exactly that- fast forwards a song but not skip it. It turns out to skip a song, you have do a CTRL-F. Of course if you have one of those keyboards with the skip button then you don't have to deal with it, but CTRL-F is the way to go for the PCs without those multimedia keyboards. Oh and to pause a song you would hit CTRL-P, and the same to resume playing. To go back to the last song, do a CTRL-B.

To make sure all these hotkeys work you have to have WMP selected as the foreground window. Then turn off the monitor, save some electricity, and party away!

D-Link QoS Engine Sample Rule to Speed Up SSH

I own a D-Link DIR-625 Router, which features a QoS Engine powered by StreamEngine Technology. I do a lot of work over SSH, and noticed that after I enabled the QoS Engine feature I got some stutter and hiccups in my SSH terminal program (I use PuTTy) while connected to a server. Apparently the "Automatic Classification" feature of the QoS engine doesn't give high priority for SSH traffic. Thankfully the setup page allows me to put in custom QoS rules. For the name field I entered in ssh, for priority I put in "2" (1 is the highest and 255 is the lowest), and the Destination Port Range I set to 22 to 22 (the port for SSH). I also did the same for web page traffic to higher prioritize it. See the image below- I hope this helps if you need to manually prioritize certain traffic with your QoS enabled router!

Monday, October 20, 2008

Prevent Comment Spam in Gallery 2

Even though I've enabled CAPTCHA I'm still seeing a ton of comment spam inserted by spambots on my Menalto Gallery 2 site. I've looked around and there are SQL queries that will rid your Gallery2 site of spam, but it doesn't prevent new ones from being saved. I've finally got sick of it and decided to stop the problem by adding a snippet of code in AddComment.inc (under the gallery/modules/comment directory). Be sure to backup your existing AddComment.inc file first before applying this mod.

Right below this section:

$comment->setCommenterId($gallery->getActiveUserId());
$comment->setHost(GalleryUtilities::getRemoteHostAddress());
$comment->setSubject($form['subject']);
$comment->setComment($form['comment']);
$comment->setAuthor($form['author']);
$comment->setDate(time());

Add the following code:

##BEGIN Gallery Spam Prevention Mod by TechBlogByDave (http://www.techblogbydave.blogspot.com)
$disallowed = array('http', 'url=');
$checks = array($form['author'], $form['subject'], $form['comment']);
foreach ($checks as $check){
foreach ($disallowed as $dis){
if (stristr($check, $dis)){
die("In order to combat spam, $check has been tagged as a disallowed keyword. Your comment has not been saved.");
}
}
}
##END Gallery Spam Prevention Mod

Save the file and voila- any comment with the text "http" or "url=" will be met with an error message and not even be saved to the datbase. You can even add additional keywords into the "disallowed" array that you don't want in comments such as cuss words. Keep in mind that when you upgrade your Gallery 2 to a newer version you will have to re-apply the mod. Hope this helps!