Simple WordPress Page Redirect Hack

May 23rd, 2011 by Don No comments »

I recently was looking for a way to setup a WordPress Page that actually was just a link/placeholder for an external site. This allows me to have my external page be automatically part of a theme’s navigation, etc. The solution I used is actually pretty simple and allows for an unlimited number of instances of these “redirect pages” without having to use any external plug-ins.

First you need to setup a simple PHP file that will serve as a template for your new page. Let’s say for example you have a club that you want to add as part of your navigation. Create a file called Club.php and put the following code in it:

<?php
/*
Template Name: Club
*/
?>
<?php header('Location: http://www.myclubsite.com');
      die();
?>

Then upload the file you created (Club.php) into /wp-content/themes/yourthemename/ where yourthemename is the name of the active theme for your site.

The final step is to create a new Page with the name that you want to show up in your navigation “My Club” based on the template that you just uploaded. You will see this template under the Template drop down menu in the page administration interface along with “Default Template”, etc.

Publish and you have a page that automatically redirects to whatever the URL you specified in your PHP template file. I create a separate one of these for any of these “redirect pages” that I want to setup.

It’s easy and it works!

Rename an email attachment before sending in .NET

April 21st, 2011 by Don No comments »

I recently had the need to send an email with a file attachment from disk. The problem I faced was that the filename was not very user friendly at all. What I didn’t want to do however was rename the file on disk, or create another copy of the file with a more generic name, that could create conflicts with other users in the system.

I was happy to find that you can simply change the attachment’s file name after you create it based on the file on disk. So my original file, 2073B129-6DFF-4088-A785-C9CD8B1AADBF.pdf, could appear as Agreement.pdf to the recipient of the email. Much better, don’t you think?

And here’s how I did it:

Attachment attachment;
attachment = new Attachment("2073B129-6DFF-4088-A785-C9CD8B1AADBF.pdf");
attachment.ContentDisposition.FileName = "Agreement.pdf";
MailMessage.Attachments.Add(attachment);

There’s obviously more to the code related to creating the message, etc. But this is what you need if you want to give the attachment a different file name.

Enjoy!

Ipad & iPhone get old school games

April 8th, 2011 by Don No comments »

Atari has released a new emulator for the iPhone and iPad called Atari’s Greatest Hits [iTunes]. The free universal download comes with Pong and also offers a selection of 100 classic Atari arcade and 2600 console games for in-app purchase. The full list of games can be seen here but include Asteroids, Centipede, Crystal Castles, Gravitar, Star Raiders, Missile Command, Tempest, Battlezone, and much more. Each 4-pack is offered for $0.99 or all 100 games can be purchased for $14.99.

Growing up with Microsoft

March 3rd, 2011 by Don 1 comment »

I first got started with computers back in the 80′s with a Tandy 1000 Series computer and used MS-DOS quite a bit.  I then graduated from DOS and worked my way through all the Windows versions over the years.  Today I came across this blog post that shows what happens if you try to upgrade a machine from MS-DOS to Windows 7.  Watching this really took me back and made me realize how I really have grown up with Microsoft over the years.

I still use Windows 7 daily at work today and for various non-work related programming.  I have also branched out and use Mac OS X for all of my core personal computing these days.  What really shocked me about the video in was that it showed that you really can take a computer from MS-DOS and apply 20 years worth of software upgrades to it and have it still work.  I must say I was impressed by this and Microsoft actually earned back some of my respect!

For those of you that aren’t familiar with the earlier versions of Windows or MS-DOS (Disk Operating System), enjoy this video!

How to use the My Namespace in C#

February 22nd, 2011 by Don No comments »

When I was first trying to transition from VB.NET to C# I found it pretty odd that the “My” Namespace wasn’t available in C#.  If you aren’t aware of what I’m talking about, the Microsoft.VisualBasic.MyServices namespace (My in Visual Basic) provides easy and intuitive access to a number of .NET Framework classes, enabling you to write code that interacts with the computer, application, settings, resources, and so on.

After a little hunting I discovered that by simply adding a reference and a using statement that I could be up and running with my beloved My classes that I had come to know and love.  Here’s how you do it…

Add a Reference

  1. In Solution Explorer, right-click the References node, and select Add Reference.
  2. When the References dialog box appears, scroll down the list, and select Microsoft.VisualBasic.dll.You might also want to include the following line in the using section at the start of your program.
    using Microsoft.VisualBasic.Devices;

Example

This example calls various static methods contained in the MyServices namespace. For this code to compile remember that we added a reference to Microsoft.VisualBasic.DLL in the step above.

using System;
using Microsoft.VisualBasic.Devices;
 
class TestMyServices
{
    static void Main()
    {
        // Play a sound with the Audio class:
        Audio myAudio = new Audio();
        Console.WriteLine("Playing sound...");
        myAudio.Play(@"c:\WINDOWS\Media\chimes.wav");
 
        // Display time information with the Clock class:
        Clock myClock = new Clock();
        Console.Write("Current day of the week: ");
        Console.WriteLine(myClock.LocalTime.DayOfWeek);
        Console.Write("Current date and time: ");
        Console.WriteLine(myClock.LocalTime);
 
        // Display machine information with the Computer class:
        Computer myComputer = new Computer();
        Console.WriteLine("Computer name: " + myComputer.Name);
 
        if (myComputer.Network.IsAvailable)
        {
            Console.WriteLine("Computer is connected to network.");
        }
        else
        {
            Console.WriteLine("Computer is not connected to network.");
        }
    }
}

Not all the classes in the MyServices namespace can be called from a C# application. You can visit this MSDN article that details more on what’s not supported.

Use ASP.NET and DotNetZip to Create and Extract ZIP Files

February 16th, 2011 by Don No comments »

I recently came across this article from Scott Mitchell, that shows how to use DotNetZip to create and extract ZIP files in an ASP.NET application, and covers advanced features like password protection and encryption.

The article details all that you can do with the feature-rich, free, open source ZIP implementation for .NET - DotNetZip. Using DotNetZip and a dash of .NET code you can:

  • Create a new ZIP file and add one or more files or folders,
  • Read the contents of a ZIP file,
  • Extract all (or some) of the contents of a ZIP file to a specified folder,
  • Use advanced ZIP file format features, such as encrypting the contents of the ZIP and protecting them with a password.

This is definitely something that will come in handy.  I’ve tried working with zip files in the past and it has never been this easy.  Dealing with a ZIP file is definitely something that you will need to do at some point if you program long enough.  With this article, it will definitely be something that you won’t bang your head against the wall trying to accomplish!

ProClip, the BEST iPhone mount you can find!

February 15th, 2011 by Don 1 comment »

My 2010 Toyota Prius is a great car!  It’s a geek’s dream with all the hi-tech bells and whistles it has.  For example, I use the Bluetooth integration in the car quite a bit for both talking on the phone and audio (music, podcasts, etc).  With the phone being the main source for audio entertainment, there are many times I need to access it while driving (change a song, fast forward through a podcast’s commercials, etc).  Unfortunately, half the time I needed it my phone it had slid off the passenger seat where I had it plugged in charging or was out of reach.

The only usable factory option was the cup holder in the center console but most of the time I have my coffee or water in there.  I researched various options and could never really find a good way for my iPhone to sit while I was driving, especially when I had a beverage in my cup holder.  Unfortunately the Prius’ design doesn’t really lend itself to the traditional vent or window iPhone mount.

Finally the other day I stumbled upon the ProClip website and realized there was still hope.  ProClip had a proprietary two part system that looked legit and that seemed perfect for how my Prius was laid out.  I ordered the item and it arrived in just a few days.  After a quick 15 minute install I must say that I’m glad I pulled the trigger on the ProClip.  Like I said, the system has two parts.  You first install the base mount and then you get your device specific holder (my links are to the specific parts I ordered for my 2010 Prius).

If you look around you’ll see there are numerous options for the device holder with various prices.  I opted to get a slightly more expensive one that had a pass-through for the phone charger, just so I didn’t have to hook that up each time I put the phone into the mount (yes, I’m that lazy).  If you want to spend less money there are options there for you when it comes to the device holder.  The mounts are more cut and dry (vent mount, console mount, etc).  That really depends on where you want it to be.

So far the holder has been great.  I was able to have my coffee in my cup holder, my phone angled where I could easy see and control it, and everything seemed solid.  I do have to get used to getting the phone in and out of the holder, but I think that’s something that will get easier over time, and the holder will get broken in allowing the phone to slide in and out without much effort.  The holder is padded and has a very good quality finish.  I can tell it will never scratch the phone or allow the phone to fall out.  And while I haven’t used it, it supports both vertical and horizontal modes.

If you’re looking for a decent mount for your iPhone, and you don’t mind a more permanent option, definitely consider the ProClip mount!

My Must Have Jailbroken iPhone Apps

February 9th, 2011 by Don No comments »

The iPhone 4 is an awesome smartphone.  It truly has started to replace my desktop and laptop computer for many day to day tasks.  While Apple did a good job at making this phone very user friendly and functional, you can really make this tiny little pocket computer even better without much effort.  Jailbreaking your iPhone will really unleash this device’s true power and will fix/help the few flaws and/or limitations that Apple, or your carrier, has placed on this device.

Since I recently updated my phone to the latest iOS version, 4.2.1, I figured I’d share with you the latest tool I used to jailbreak the phone and the few of my “must have” jailbroken apps.  I won’t go into much detail about how to install the jailbreak or each individual app, there are plenty of resources available on the topic.  I just wanted to share which apps I have come to love and depend on, which have made me love my iPhone even more.

First, Jailbreak it (Guide for Windows, Mac).

Second, the apps…

My3G

Facetime over 3G! Take back your 3G! My3G makes Apps believe that they are on WiFi instead of 3G. With My3G, you can now watch HiDef YouTube videos, use Skype/Fring/Other VOIP apps over the 3G network!

MyWi 4.0

Create an iPhone WiFi HotSpot or iPad WiFi HotSpot with a press of a finger! Wherever you are – you can connect your laptop or other mobile device to your iPhone/iPad easily to use your iPhone/iPad’s data connection.

Wi-Fi Sync

Wi-Fi Sync enables wireless syncing with iTunes at the touch of a button. Never go looking for that USB cable again. Sync from the car, bed or shed whenever it suits you.

LockInfo

Gives you access to your information where you need it, when you need it. You can view your new emails, upcoming calendar events, unread SMSs, missed calls and much more on your lockscreen.

biteSMS

Takes all of the basic features of the built-in Messaging app, and adds many more great features.

SBSettings

Offers a faster method to manage iPhone settings like rebooting, turning on/off Wi-Fi, 3G, Bluetooth, etc.

Easily Disable JavaScript Debugging in Visual Studio 2008

December 15th, 2010 by Don No comments »

Visual Studio 2008 is not without its faults.  They did however add some nice features in the 2008 release such as JavaScript debugging.  This feature is great when you need it, but can drastically slow down your debugging experience if you don’t need it or use quite a few “script heavy” controls like Telerik Radcontrols.

So after dealing with this for a while and taking enough productivity hits I decided to find a way to disable the Script Documents folder that shows up when running in debug mode.

It didn’t take long to stumble across this blog post where the blogger made a VisualStudio add-in to make turning this on and off as needed easy via a toolbar button.  After reading the post and downloading the utility I was debugging without the old lag that I had before caused by all of the JavaScript documents that were loaded.

If you’ve run into this and feel this would be helpful, I can say that it seems to be working fine for me.  I was a little worried too considering I run Windows 7 but it seems to still work well without any permissions issues.

CMAP Main Meeting – Tuesday, December 7th – IIS Express, Razor, and WebMatrix, OH my!

December 7th, 2010 by Don No comments »
CMAP Main Meeting – Tuesday, December 7th – IIS Express, Razor, and WebMatrix, OH my! – G. Andrew Duthie

When: Tuesday, November 7th, 6:30 PM – 9:00 PM

Where: HCC Business Training Center, 6751 Columbia Gateway Drive, MD, 21046

Topic: IIS Express, Razor, and WebMatrix, OH my!

Does the announcement of so many new technologies make you wonder where the yellow brick road is that will lead you to the Oz of understanding? Well, there’s no denying that there’s a lot to keep up with these days if you’re a web developer. So let Microsoft Developer Evangelist G. Andrew Duthie give you an overview of Microsoft WebMatrix, ASP.NET Web Pages, the new Razor syntax, and IIS Express, and how they fit in with the existing offerings in Microsoft’s web stack.

Learn how and when you’d want to leverage these new technologies, and when existing technologies may be a better choice. Expect discussion and demo, and bring your questions, so we can make this an interactive and dynamic session!

Presenter: G. Andrew Duthie

G. Andrew Duthie, aka .net DEvHammer, is the Developer Evangelist for Microsoft’s Mid-Atlantic States district, where he provides support and education for developers working with the .net development platform. In addition to his work with Microsoft, Andrew is the author of several books on ASP.NET and web development, and has spoken at numerous industry conferences from VSLive! and ASP.NET Connections, to Microsoft’s Professional Developer Conference (PDC) and Tech-Ed. Andrew is also the creator and developer of Community Megaphone, a site designed for promoting and finding developer community events. Andrew can be reached through his blog at http://blogs.msdn.com/gduthie or on Twitter at @devhammer.

For more information about the meeting, please visit the CMAP website.