Web Design
FMyScript Disappearing Voting Links
I was recently asked to work on a site running FMyScript. The problem was this every time a voting link was clicked the link would just disappear and the votes were not updated.
The solution was two fold:
Part 1:
The first problem was the voting links has a ‘ in the string such as “I’m really sad to hear that” So I just changed the string instead of finding all the places I might have to escape it. I figured I am is better grammar anyways.
Part 2:
The domain must the config file. That means if you set up your site with the www in the url and someone goes to your site without the www in the url the voting system will not work.
I modified the .htaccess files to force www by adding the following lines:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.your_domain.com$
RewriteRule ^(.*)$ http://www.your_domain.com/$1 [R=301]
I hope this helps someone.
Simple XML Parse Flickr Feed
So in one of my recent projects I had to parse a Flickr feed and extract the image urls the code I came up with is as follows:
<?php
/* Author: Samuel Haddad
* SimpleXML Flicker Feed Parser
*/
//Feed URL in RSS Format
$url ="http://api.flickr.com/services/feeds/photos_public.gne?lang=en-us&format=rss_200"; //FEED URL
//Use simple XML to parse the feed
$xml = simplexml_load_file($url);
$items = $xml->xpath('/rss/channel/item');
foreach($items as $item){
$nsmedia = $item->children('http://search.yahoo.com/mrss/');
$img = $nsmedia->content->attributes();
echo $img; //URL of Image
echo "<br/>";
}
?>Of course my code did more then just extract the URL, but I will leave the rest up to the creative developers.
2 Plugins to Eliminate WordPress Spam.
Akismet
Many avid bloggers are already familiar with Akismet and rightfully so. Akismet does an amazing job of eliminating spam. It will catch 99% of spam and put it in the spam queue. Head over to http://akismet.com/ and install Akismet. You will need to sign up for a WordPress account and get an API key. Don’t worry it takes 2 seconds and is worth it. Once Akismet is installed need to go to your Akismet Configuration, which is under plugins, and enter your WordPress API key. There is also a check box label “Automatically discard spam comments on posts older than a month.“ I chose to uncheck this. With this checked if Akismet detects spam on a post you wrote over a month ago it will just delete it. While Akismet is really good there is a chance you could lose some legitimate comments. If you combine this plugin with the one below there is really no use for this. However the choice is yours. After that it is just a matter of waiting and letting Akismet do its work.
Akismet will install a little control panel to view statistics it will look something like this:
From the WordPress dashboard you will want to check your Spam Queue to make sure that no legitimate messages get through. It does not happen often, but it does.
WP-Ban
Akismet does an amazing job of stoping spam comments from getting to your inbox. How about stoping spam before it ever gets submitted? That is were WP-Ban comes in. WP-Ban can be found at http://wordpress.org/extend/plugins/wp-ban/.
Basically this can be used to block anyone from ever viewing your blog on the IP level. Granted many spammers will jump though proxies and use 10 different IP’s in a minute. I noticed that I was getting 100′s of spam comments from 1 or 2 IP addresses. I would block that one IP for example the following 4 IP addresses accounted for over 400 spam comments in a day:
194.8.75.149
194.8.75.163
194.8.75.220
194.8.74.220
Blocking those 4 IP address pretty much stopped my spam.
I would be very selective in blocking IP addresses, do not use ranges and never block your own IP. Over the past week I have seen spam almost stop dead in it’s tracks.
Visual Studio Tips and Tricks
Alternate Case/Format selection:
Have you ever been asked to update some code from a long time ago only to find that almost every tag is in capital letters? AGHH!
<HTML> <HEAD> <TITLE>My Really Old Site</TITLE> </HEAD> <BODY> <P> Lots of body test </P> <P> Lots of body test </P> <P> Lots of body test </P> <IMG SRC="mypic.jpg" width=351 height=113> </BODY> </HTML>
Highlight all that code and press CTRL + K then CTRL + F and you will format all the code. It would then look something like this
<html> <head> <title>My Really Old Site</title> </head> <body> <p> Lots of body test </p> <p> Lots of body test </p> <p> Lots of body test </p> <img src="mypic.jpg" width="351" height="113"> </body> </html>
Granted your code may still be far from perfect, but it is definitely a huge help.
Key Launcher (Like Alt + Tab on Windows)
Are you someone that lives by keyboard shortcuts? I know I am. Are you familar with Windows Alt + Tab keyboard shortcut and toggling through all active programs? Well a similar feature exists within Visual Studio press Ctrl + Tab and toggle through your active Windows and Files.

Intellisense
Control + Spacebar will bring up intellisense if you are in code view. Great if you click out by accident or you just want to see what is available in the scope of the code.

Break Points
Have a bunch of break points scattered over a couple of files in a solution. Just want to delete them all and start fresh. Ctrl + Shift + F9 will delete all current break points in a solution. Don’t worry Visual Studio will prompt you with a confirmation first.
Get Visual Studio Professional for free!
Well maybe. If you are a student like myself you can head over to https://www.dreamspark.com/which is run by Microsoft. They offer full versions of some of the newest Microsoft products, like Visual Studio. Why? Because they know we are the future and they think we are an investment. Take them up on the opportunity and get ahead of the competition.
Shortcut key posters:
Microsoft Visual Studio has a bunch of keyboard combinations that can be very helpful, to get a more complete list check out some of the resources Microsoft offers:
Visual C# 2008 Keybinding Reference Poster
Visual Basic 2008 Keybinding Reference Poster
Visual C++ 2008 Keybinding Reference Poster
Visual C# 2005 Keyboard Shortcut Reference Poster
Overwriting an Excel file destination using SSIS
This was a problem I racked my brains over for a while when I first started using SSIS. I found a few possible including using a File System task to copy a “Template” Excel file over the existing on, or generating unique files by appending the date. I simply wanted to overwrite the existing data just like the Flat File Destination gives you that option.
My work around was as flows:
Create the Data flow the way you normally would, then go to the Control View Then add two Execute SQL Tasks before your data flow is called so it looks like this

Step 1: Add Execute SQL Task 1 to Control Flow
Set both Execute SQL Tasks to use the Excel file

Step 2: Set Connection Manager
Set your first Execute SQL Task’s SQL Command drop your table which is also known as the sheet name of your Excel file.

Step 3: Drop Table
Repeat step 3 on the second Execute SQL Command this time create your tables.
That’s it. Good luck.

