Using Visual Studio AutoRecover to Avoid Losing Your Work (and your Mind)


If you have ever worked in an environment that may not have been the most reliable or you are simply a worry-wart when it comes to possible data loss, then this might be for you.

When discussing a recurring issue with another developer, he complained that his older computer frequently crashed which resulted in him losing data quite often. He didn’t seem to be aware of a feature within Visual Studio called AutoRecover that would help him ensure that his data wasn’t always “gone forever”. While it typically works on it’s own, this post will discuss AutoRecover, configuring it and locating all of the temporary files it creates if you need to find them.

What is AutoRecover?

AutoRecover is an option within Visual Studio that will allow you to define a particular interval in which to save information about all of the files that may be changing or have changed within your application. It’s perfect for scenarios where you might have a machine that is on the verge of death, intermittent power issues, data-loss anxiety and just about anything else that might have you spouting off expletives when your screen goes black (or blue).

How do I use it?

You can access the AutoRecover option in Visual Studio through the following steps :

  1. Select Tools from the Toolbar in Visual Studio.
  2. Choose Options
  3. Select AutoRecover beneath the Environment tab on the right.

You’ll then be presented with the AutoRecover dialog box :


You’ll just need to adjust these values depending on your needs and how erratic your machine can be.

Accessing AutoRecover Files

Accessing the files themselves is quite easy as well. By default, Visual Studio will store all of these files within a “Backup Files” directory which is typically located at the following location :

~/Documents/{Your Version of Visual Studio}/Backup Files/{Your Project Name}

Within this folder, you will see a collection of files that are both original and those that have been previously recovered as seen below :


Visual Studio will typically prompt you to open these files if your system experienced an unexpected shut down when opening an affected solution or project, but this should provide an easy way to access these files if things do go horribly wrong.


This simple hack gives your Windows XP five more years of updates!!!

With a simple registry hack, you can net yourself five more years of official Microsoft updates for your aging Windows XP machine. Microsoft, though, says you really shouldn’t do it — and that you ought to be a good little boy and “upgrade to a more modern operating system” instead.

Microsoft technically ended support for Windows XP on April 8, 2014.

But if you were a big company or government with lots of money, Microsoft offered to continue supporting your XP machines — and then, when a zero-day vulnerability was found, Microsoft fixed that, too. And now, it seems there’s an easy way to gain five more years of support.

How to give Windows XP five more years of updates

Fire up regedit. Navigate to HKEY_LOCAL_MACHINE\SYSTEM\WPA\. Create a newKey called PosReady. Right click the new key and add a new DWORD with the value 1. That’s it. Now head along to the Windows Update website and you should see a bunch of updates.

This simple hack tells Windows Update that your computer is running Windows Embedded POSReady, rather than Windows XP. POSReady, which as the name suggests is for point-of-sales cash registers, is a variant of Windows XP that was released in 2009 — some eight years after Windows XP was first released. Most people are not entirely sure why Microsoft released a variant of Windows XP about six months before the release of Windows 7, but there you go. POSReady will be supported until April 2019.

Windows XP updates just magically appear if you perform a simple registry hack [Image credit: ZDNet]

Should you use Windows XP for five more years?

This is what Microsoft has to say about this rather ingenious little hack:

We recently became aware of a hack that purportedly aims to provide security updates to Windows XP customers. The security updates that could be installed are intended for Windows Embedded and Windows Server 2003 customers and do not fully protect Windows XP customers. Windows XP customers also run a significant risk of functionality issues with their machines if they install these updates, as they are not tested against Windows XP. The best way for Windows XP customers to protect their systems is to upgrade to a more modern operating system, like Windows 7 or Windows 8.1.

In short, you use the updates at your own risk.

However, Windows Embedded POSReady is really similar to Windows XP. It makes sense, if you think about it: Windows XP already has the software, driver, and developer support… so why shake things up? Why make the barcode scanner manufacturer target some arcane platform, when Windows XP is already a tried and tested entity? If you’ve ever taken a peek behind the counter, they even look like desktop PCs in many cases.


But just because these POSReady updates will probably work with your Windows XP machine doesn’t mean you should do it. Yes, Microsoft has a vested interest in getting you to upgrade to Windows 7 or 8 — but, to be fair, unless you have a really important reason for sticking with XP, it really does make sense to upgrade to Windows 7.

If you do use the hack, don’t assume that your XP machine will be safe from exploits. There’s also every chance that, one day, one of the updates will make your system unbootable. A much better alternative, if you don’t want to work out the money for Windows 7 or 8, is to try out Linux.

How to use the Visibility API

Browser tabs have revolutionized the way we browse the Web, but they’ve given us an tricky problem: developers can’t tell if the tab their site is displayed in is being viewed.To solve that problem we have the Visibility API, which allows us to test whether the browser content can be seen, and respond accordingly. It’s ideal for sites that play music for example, to pause the playback whilst the user is away. The Page Visibility API comes with several properties:

  • document.hidden: This property returns true if our page is hidden from the user. If it’s minimized or in a different tab.
  • document.visibilityChange: This will trigger every time there is a change in the visibility of your page.
  • document.visibilityState: This will tell you if your website is visible, hidden or in pre-render state.

These simple properties go a long way to allowing us to detect how a user is interacting with our site. Browser support for this feature is good. All modern browsers support it, and you only really need the -webkit-prefix for Android and Blackberry browsers. Let’s take a look at the code we need:

var hidden, state, visibilityChange; 
if (typeof document.hidden !== "undefined") {
    hidden = "hidden";
    visibilityChange = "visibilitychange";
    state = "visibilityState";
} else if (typeof document.webkitHidden !== "undefined") {
    hidden = "webkitHidden";
    visibilityChange = "webkitvisibilitychange";
    state = "webkitVisibilityState";

As you can see, we test whether document.hidden is undefined and then assign variables based on the result. (This technique was first implemented by Sam Dutton back when there were a lot of prefixes to concern ourselves with. Next, we need to listen for changes in the visibility state, which we do with a listener:

document.addEventListener(visibilityChange, function() {
 // Code to manipulate the document    
}, false);

Now we’re listening for a change and running a function each time it occurs. We can do anything we like inside that function; for the purposes of demonstration we’ll change the message on the page:

document.addEventListener(visibilityChange, function() {
    if(document.visibilityState == hidden) {
        document.title = ' Where are you going?';
    } else {
        document.title = 'Oh good you are back.';
}, false);

This code doesn’t affect the page when it first loads, only if the user changes the visibility of the page. If you want to set a different message as soon as the page loads you’d use something like:

document.title = 'Default Title';

Just by adding this the page will use this as default and then change the title according to the visibility state.

Send Anywhere: A Peer-To-Peer File Sharing Service

Like DropboxBox, and Google Drive, ESTmob’s Send Anywhere offers file sharing–but with a key difference. Instead of first saving files to cloud storage, Send Anywhere enables users to share content peer-to-peer between devices in real time.

Send Anywhere lets users share files by pairing two devices and using a temporary key confirmation, which means it requires no registration or login.

It is targeted towards people who want to access files on multiple devices and is currently available for free as an online service or on iOS and Android.

In an email, co-founder Suhyuk Kang told TechCrunch that Send Anywhere’s peer-to-peer sharing is faster than its competitors for sending many large files at once.

“Most people using multiple devices use them in the same local network, or in very close range. Why go through the cloud?” he explained. “Cloud servers are likely to be a very long distance from the user’s device. It’s slow, there are security concerns, and it’s expensive.”

Another potential competitor is WhatsApp and other messengers that allow photo- and video-sharing, but Kang says Send Anywhere preserves the quality of image files while letting users send large batches of data–more than 100 photos or 2GB of videos.

Send Anywhere’s next major update is remote access for registered devices, that will create a user experience closer to services like Dropbox while still bypassing the need for a cloud server.

Send Anywhere on mobile

Placing Your C# Application in the System Tray

There are many cases when it’s advantageous to place an application’s icon in the System Tray.

For example, firewall/antivirus and instant messaging applications do this so as to run in the background and still be accessible to the user without crowding up the task bar.

Here’s a fine .NET Technique that will show us, the steps involved in specifying that an application is to be minimized to the Tray, how to allow the user to restore the application by double-clicking the icon and how to create and respond to a System Tray icon’s context menu.

To get started, open an existing C# Windows form (or create a new one):

  • Open the Visual Studio Toolbox.
  • Drag a NotifyIcon control onto the form. The control will named notifyIcon1 by default and placed below the form because it has no visual representation on the form itself.
  • Set the NotifyIcon control’s Text property to the name you want to appear when the user pauses the mouse over the application’s icon. For example, this value could be “KillerApp 1.0”.
  • Set the control’s Icon property to the icon that you want to appear in the System Tray. Tip: If you have a BMP file that you want to convert to an icon file, you can use the QTam Bitmap to Icon 3.5 application.
  • Add an event handler for the form’s Resize event that will hide the application when it’s minimized. That way, it won’t appear on the task bar.
private void Form1_Resize(object sender, System.EventArgs e)
   if (FormWindowState.Minimized == WindowState)
  • Add an event handler for the NotifyIcon.DoubleClick event and code it as follows so that the application will be restored when the icon is double-clicked.
private void notifyIcon1_DoubleClick(object sender,
                                     System.EventArgs e)
    WindowState = FormWindowState.Normal;

At this point, your application should function perfectly in terms of an icon appearing in the System Tray when the application is run (see image below), the application not appearing on the task bar when minimized and the application restoring itself when the Tray icon is double-clicked.


Now, let’s see the steps involved with adding a context menu to the icon.

  1. From the Visual Studio Toolbox, drag a ContextMenu control onto the form.
  2. Right-click the ContextMenu control and select the Edit Menu.option.
  3. Type in the options that you want to appear in your context menu. For example, you can add options such as Restore and Close Application.
  4. As with any menu, double-click the menu item to create and code each item’s handler. As an example, you could copy the code from the form’s DoubleClick handler into the context menu’sRestore handler and for the Close Application menu item; simply call the form’s Close method.
  5. Finally, set the NotifyIcon control’s ContextMenu property to the new context menu you just created by selecting the menu from the drop-down list. Figure 2 shows a simple Tray context menu.




Much safer way to restart your frozen Linux

Somehow, you crashed your Linux. It’s completely frozen. You try pressing Ctrl + Alt + Backspace, but doesn’t help.

What to do? Someone would press the power button and restart or shut down the system.You shouldn’t do this. This can make you a lot of problems.

What you can do, is to perform a gentle Linux restart.  This is much safer way to restart your frozen Linux.  To do this, you need to press:

Ctrl + Alt + PrtSc (SysRq) + reisub

Just to make it clear. You need to press and hold Ctrl, Alt and PrtSc(SysRq) buttons, and while holding them, you need to press r, e, i, s, u, b

This will restart your Linux safely.

It’s possible that you’ll have problem to reach all the buttons you need to press. I’ve seen people type reisub with their nose 🙂

So, here’s my suggestion: With your smallest finger on the left hand, press Ctrl. With your thumb on left hand, press Alt. With the smallest finger on your right hand press PrtSc(SysRq) button. This way, you’ll be able to access to reisub buttons with your other fingers.

Okay, but what this REISUB means?

  • R: Switch the keyboard from raw mode to XLATE mode
  • E: Send the SIGTERM signal to all processes except init
  • I: Send the SIGKILL signal to all processes except init
  • S: Sync all mounted filesystems
  • U: Remount all mounted filesystems in read-only mode
  • B: Immediately reboot the system, without unmounting partitions or syncing

You can find the complete list here. There you can see that o shuts down the system. So, if you want to turn off your PC when your Linux crash, you can use this combination:

Ctrl + Alt + PrtSc (SysRq) + reisuo

Add Your Own Page Load Progress Bar With Pace.Js

For some users, a progress bar can be a very useful thing. It informs them of how much closer they are to completing tasks. Normally, this is used to give a more user-friendly experience. When you open a webpage on your favourite browser, there is already a default progress bar in the browser tab to see if the page is completely loaded.

With Pace.js, you can now incorporate the page load progress bar into your own page.

Pace.js is a jQuery plugin to create a beautiful page load progress bar in a website. The progress is established automatically by inspecting ajax requests, document ready state, event loop lag (showing that javascript is being executed) and the existence of specific elements on a page.

When an ajax navigation or a pushState event takes place, the progress bar will also be restarted again.

Getting Started

Pace.js is very easy to implement. It can be used even without having jQuery library in your site. You just need to incorporate pace.js and a CSS theme of your choice as early as possible into your document:

  1. <head>
  2.   <script src=”../pace.js”></script>
  3.   <link href=”../themes/pace-theme-corner-indicator.css” rel=”stylesheet” />
  4. </head>

That’s it! You’re done and your site now has a beautiful page loading progress bar.


Substance wise, there’s no need for additional configuration as Pace.js comes with full automation. But if the default setting doesn’t meet your needs, you can use your own configuration as well.

To customize further, there are two simple methods you can choose. First, by including configuration inside window.paceOption like the following.

  1. <script>
  2. paceOptions = {
  3.   // Configuration goes here. Example:
  4.   elements: false,
  5.   restartOnPushState: false,
  6.   restartOnRequestAfter: false
  7. }
  8. </script>

A second method is where you can easily add data-pace-options inside a script tag then define the configuration and call the pace.js resource like so.

  1. <script data-pace-options='{ “ajax”: false }’ src=’pace.js’></script>

You can find the complete list of available configurations you can use in the source page.

Final Thought

This plugin comes with a bunch of ready-to-use themes. To see the full list and demo of the themes, you can head on over to the plugin site. If those themes don’t suit you, you can easily create your own. With the help of a plugin like Pace.js, now you don’t have to worry about difficulties in implementing a loading page progress bar into your site.

Awesome trick to validate Email Address in C# .Net (without Regular Expression)



Recently I came across this fine, precise, code by Rion Williams, to check and validate an Email Address.
The code uses System.Net.Mail Namespace to check email address and returns True/False.

Very Effective and Easy!

Source Link

bool IsValidEmail(string email)
    try {
        var addr = new System.Net.Mail.MailAddress(email);
        return true;
    catch {
        return false;

Please feel free to share your thoughts, Or similar code you’ve encountered recently in Comment section.