MVC - How to disable Script Buldling Minification for debugging

Trying to debug scripts can be a pain in the neck if you are using bundling and Minification to optimize your script size.

I have actually seen a few cases where IE ( 11 ) would not render correctly unless I disabled bundles.

You can still use bundles to have a single place to put all your scripts, but to disable minification you set EnableOptimizations  to false as shown below.

Open the App_Start/Bundle.Config file and add the following line of code.

BundleTable.EnableOptimizations = true;

That's all there is to it.

Now the script files should be generated out so you can set nice breakpoints and debug code.

Happy scripting.

When to use Encryption -vs- One way Hash Data in your Database

What is Encryption?
Encryption is scrambling data so that it can be only be read someone who has the correct decryption key to unscramble it.

What is Hashing?
As defined a one-way hash function is designed in such a way that it is hard to reverse the process.

Had a recent discussion with another programmer on when to hash information into a database and when to use encryption in a way to be decrypted for later use.

I thought about this for a while and this is what I decided is best practices.

First of all I am using the term Encryption very loosely. All personal client data should always be encrypted in some way.

Use Encryption Keys or Certificates that can be used to encrypt / decrypt information that is considered PCI.
PCI = ( Payment Card Industry Data ) that you need to keep on file and continue to have access to, this way you can still get to the data when you need it but it would be hard for a hacker to make any use of it.

All of the following items should always be hashed into your database and should never be able to be decrypted.
Any and All Passwords - Hashed
Two factor answers to questions like mothers maiden name - Hashed

Best Practices Example:
User (a) creates an account on your website, they select a password and several answers to questions. When you store the information into your data base you use a HASH key to encrypt the data.

When User (a) comes back to your website they try to login you take their password - hash the value - then compare the hashed value with the ( hashed value ) stored in the database. If they match then they entered the correct answer. Otherwise they are not allowed into the system.

The reason is because you never need for anyone to be able to see this information every again! This information is more private than credit card details, and can be used against a user on other websites, and even on phone calls to companies.

Why would you say this is a best practice? Don't be the weakest link!!

Think about it this way, people are creatures of habit, they tend to use the same user Id and password on multiple websites, they answer the same or slightly different questions in the same way, so if their ID and password, and two factor answers are compromised on your website by some hackers then it's a good chance they now have access to other sites like facebook, yahoo, etc. Don't be the weakest link in the chain of websites that is the internet.

Encryption Items for you to research:
Public & Private Keys
MD4 & MD5

How to set the orientation on Windows 8 Phone

How to set the orientation on Windows 8 Phone.

Currently I am using Corona Cards ( alpha ) for Windows 8 game development.

I needed to set the Orientation for the application. I have done this before in normal sample windows 8 phone apps but I could not recall how to. Well someone asked the question before I could and here is the answer.

Visual Studio 2013

Set the orientation in your "MainPage.xaml" file's xml according to Microsoft's documentation.
Coding it will work as well, but doing it via XML is simpler.

Do the following:

1) Double click on "MainPage.xaml" in Visual Studio's "Solution Explorer" panel.
2) Observe the Page node in the XML editor.
3) Change the "SupportedOrientations" attribute's value to "Landscape".
4) Change the "Orientation" attribute's value to "LandscapeRight".

Apple Macbook Pro Battery Won't charge, Battery Not Charging

I have a Apple Macbook Pro Model 2010 Mid, I had not worked on or charged it in about two to three months. I decided I was to take it to a local mobile game and app developers Meetup, so i placed it on the charger in the morning before I left for work.

When I turned on the computer the computer informed me that my date and time was set to the year 2000 ( The computer must have been completely dead because to have lost my settings for date and time ).

I then noticed that the battery still indicated that it had 0% charged and that it was running on the power cord.

A call to Apple support helped me figure out the problem:

The light on the cord plugged into the computer is GREEN ( meaning fully charged )
When the computer is turned on the battery status still indicates that it had 0% charged and that it was running on the power cord.

Issue ( the computer system no longer seem that it has a batter in the computer )

Resolution: Perform a System Reset or recycle:
Shut the apple computer down ( do not put it to sleep, it needs to be a full shut down )
While still shut down and plugged up to the charger, on the keyboard hold down the following 3 keys ( SHIFT, CTRL, OPTION)  while holding these keys down also press and hold the Power  button ( continue to hold all keys and power button for about 15 to 20 seconds ). Release all of the keys and the Power button at the same time. 

After you have completed this, turn your computer back on. After it boots up give it a couple minuets to finish and look at the light on your cord, the light should switch to amber and the batter indicator should indicate the number of hours and minuets that it will take to charge ( like 2:30 ) or it could say something like calculating charge time,

Either one should be indicate that you are good to go. Just leave it on the charger for a few hours and you should be good to go.

If that does not fix it.  Call Apple :)

Good Luck,

Deploying Apps to your Windows 8 RT Device

Deploying apps to your Windows 8 RT Device

NOTE: In order to deploy to a remote RT device "Wirelessly' you need to be on the same WIFI connection where Visual Studio can open some ports and talk to the device. If your router or firewall is blocking the ports then you need to use a USB Adapter.

To deploy your apps to a Windows RT device for testing you first need to download the Remote Tools for Visual Studio onto your actual Windows RT Device.

NOTE: you download this application on your Windows RT Device with the Web Browser on that device

There are two version to choose from.

Remote Tools for Visual Studio 2013

Remote Tools for Visual Studio 2012 Update 4

Click the download link button and you will see a screen that will list 3 different files for the differnent type of chipsets, find your version based on your device and download it.



rtools_setup_x86.exe - this was mine

After you download the application, install it.

(This is a desktop application that runs on your windows rt device and links to visual studio through your local WIFI. Some ports are opened and there is some handshaking that goes on when you are using it together with visual studio on your desktop computer)

Now that the application is installed on your Windows RT Device, find it listed in your application and Executed it, the name of the application is called Remote Debugger.

When the application starts a window will appear and should show you the name of the device.

There is nothing else on the device you need to do, just let the application on device continue to run.

The application is basically a monitor and transport agent for visual studio.

Now back in Visual Studio you need to switch the application run to Remote Device instead of Local Machine

If the application compiles and executes just fine then your application should be automatically transferred to you RT Device remotely over your WIFI. Depending on the Size of the Application it may take several minuets to transfer.

You can also use the USB plug to do the same thing.

IPC or Interprocess Communications in C#

Someone asked me about a sample application of IPC or Interprocess Communications using memory mapped files

What is IPC or Interprocess Communications you ask.

The easiest way to explain it is by saying it allows two application to talk to each other.

The following IPC mechanisms are supported by Windows:

Clipboard, COM, Data Copy, DDE, File Mapping, Mailslots, Pipes, RPC, Windows Sockets

Click the link below for much more details.

In this post I'll be exploring Memory Mapped Files using .net C# to allow multiple applications to talk to each other and pass information.


In the distant past I have only used DDE to allow applications to talk directly to each other so this was pretty interesting to me.

In this example I will be using Memory Mapped Files. Mapped Files are fairly easy to implement in .Net

Memory Mapped Files are implemented by using the System.IO.MemoryMappedFiles Namespace

In the example below I have two very simple methods, CreateOrOpenMappedFile, and ReadMemoryMappedFille

Note below that we briefly use Mutex ( from system.threading.Mutex ) to capture and hold the thread that we are using for communications for our memory mapped file then we release it, ensuring that we are the only one who can change it at that time.

More on Mutex here

I created one application and made a copy calling the applications app1.exe and app2.exe. Based on a command line switch I set one to be the sender and one as receiver ( actually they both act as sender and receiver. I just needed a way to specify different messages based on how the application was started ).

When using memory mapped files multiple applications can gain access to the same memory space to share messages and data, that they normally would not have access to. See the image below


The following code is really the heart of the application, the rest is just fluff. But the full application is supplied below for your enjoyment.

        //--Create or Open a memory mapped file
//----------------------------------------------------------------------------------- protected void CreateOrOpenMappedFile() { try { MemoryMappedFile oMemoryMappedFile = MemoryMappedFile.CreateOrOpen("YourMemoryMappedFileName", 100); bool IsmutexCreated; Mutex oMutex = new Mutex(true, "NonPersisterMemoryMappedFilemutex", out IsmutexCreated); StreamWriter sw = new StreamWriter(oMemoryMappedFile.CreateViewStream()); sw.WriteLine("This is a Text Message to write to the memory mapped file"); sw.Close(); oMutex.ReleaseMutex(); } catch (Exception ex) { //-- Just trap this message just incase the memory file is not mapped string sMessage = ex.Message; } } //----------------------------------------------------------------------------------- //--Open the memory mapped file and read the contents //----------------------------------------------------------------------------------- protected void ReadMemoryMappedFille() { try { MemoryMappedFile oMemoryMappedFile = MemoryMappedFile.OpenExisting("YourMemoryMappedFileName"); Mutex oMutex = Mutex.OpenExisting("NonPersisterMemoryMappedFilemutex"); oMutex.WaitOne(); StreamReader sr = new StreamReader(oMemoryMappedFile.CreateViewStream()); txtRemoteMessage.Text = sr.ReadLine(); sr.Close(); oMutex.ReleaseMutex(); } catch (Exception ex) { //-- Just trap this message just incase the memory file is not mapped string sMessage = ex.Message; } }

 Now lets see it work

Download Source Code ( VS 2012 )