Mar 21, 2012

Show/Hide hidden files and folder with a shortcut

From HowToGeek

Download Here

We’ve written a very long time ago about how to toggle hidden files in Ubuntu with a simple shortcut key. But what about keyboard ninjas using Windows instead? After doing some research, I’ve got a simple downloadable solution for you.

What I’ve done is throw together a very simple application that runs in the background and assigns the hotkey Win+H to toggle hidden files. There’s no user interface to keep it from wasting memory, but you can always customize it using the AutoHotkey script provided below instead.

Note: This application was based on an AutoHotkey script created by Lifehackercommenter turnersd, fully credited below.

Toggle Hidden Files

Once you’ve downloaded and run the application, all you have to do is hit the Win+H shortcut key while you have any folder open:

image

And presto! You’ll immediately see any hidden files in that folder, or any folders that are open.

Hit the same hotkey sequence again, and the hidden folders will disappear again. Very useful!

Installing the Hotkey

In order to install this and set it up to run at startup, you’ll need to save and extract the downloadable file, and then create a shortcut in your startup group, which you can easily access by typing the following into the location bar:

shell:startup

You could even just copy the executable in… but either way, once you’ve done that, you can double-click on it to start it.

Note that there’s no UI for this application, it runs completely in the background to limit memory usage as much as possible.

Killing the Process

Because there’s no UI, if you want to stop the application from running, you’ll need to either reboot… or use the much simpler method of opening Task Manager, finding the ToggleHiddenFiles.exe process and killing it.

Using the AutoHotkey Script Instead

The method for creating the hotkey isn’t something that I can take credit for… the credit should be fully given to Lifehacker commenter turnersd in this article about toggling hidden files with a shortcut.

Here’s the source code, which you can copy into an AutoHotkey script file:

; WINDOWS KEY + H TOGGLES HIDDEN FILES
#h::
RegRead, HiddenFiles_Status, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden
If HiddenFiles_Status = 2
RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden, 1
Else
RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden, 2
WinGetClass, eh_Class,A
If (eh_Class = "#32770" OR A_OSVersion = "WIN_VISTA")
send, {F5}
Else PostMessage, 0x111, 28931,,, A
Return

If you have problems with this source, you can also grab it from the textsnip site.

Mar 14, 2012

CSS tips on improving server performance


CSS Sprite for images: http://css-tricks.com/css-sprites/

To improve on CSS loading, instead of creating multiple images and loading separately (which incur multiple HTTP GET), we can combine those images together into 1 picture, then use the CSS to slice them up to use later on.

This technique reduce the number of HTTP GET for the images, but its has its own penalty when you want to update/change certain part in the layout of the page: you’ll have to spend more time to tweak the whole sprites instead of editing just one image.

That’s it: pros & cons, performance vs. maintainability. Anyway, most likely for production server, CSS Sprite is in favor as it offer better performance while costing a little bit on maintaining the CSS & images

Jan 13, 2012

IE CSS/JS caching issue and how to fix

This is interesting hack:

Problem:
On IE (and IE-compatible browser: Avant Browser / Maxthon…etc), JS and CSS can be cached and not loaded when you want.

For e.g: you have 2 different global.css files to use before and after user login (don’t ask me why) . In your index.htm you may load your CSS:


<link href="/Styles/global.css" rel="stylesheet" type="text/css"/> //issue goes here

global.css <<before login>>
#header { color: #ccc; }

global.css <<after login>>
#header { color: #fff}

Now if you login, the #header color is still #ccc !

Root cause: IE cached files and do not refresh the global.css. On Chrome/FF, the browser is able to detect changes and reload your new global.css

Solution: add in a dynamic query string to let browser know there is a change in the path (URL specific). Browser will reload the CSS for you

<link href="/Styles/global.css?v=<%= DateTime.Now();%>" rel="stylesheet" type="text/css"/> //issue go away

That’s it ! The dynamic link will force browser to reload CSS /JS every time.

Notes: Only use it for files that are frequently changed, otherwise you’ll reduce performance.

Oct 28, 2011

Fix IIS error System.ServiceModel.Activation.HttpModule

 

If you hit this error, probably you are install .NET 4.0 after you installed IIS:

Could not load type ‘System.ServiceModel.Activation.HttpModule’ from assembly ‘System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′.


Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.


Exception Details: System.TypeLoadException: Could not load type ‘System.ServiceModel.Activation.HttpModule’ from assembly ‘System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′.

Solution:

Just run this command from Visual Studio Command Prompt:

aspnet_regiis.exe /i

The aspnet_regiis.exe is in

  • %windir%\Microsoft.NET\Framework\v4.0.30319
  • %windir%\Microsoft.NET\Framework64\v4.0.30319 (on a 64-bit machine)

Sep 24, 2011

ASP.NET disable a button during postback

http://encosia.com/disable-a-button-control-during-postback/

Postback Ritalin has been getting a lot of search hits intended to find a button disable technique for full .NET postbacks. So, this example is for all of you searching for a non-AJAX solution.

The trick is to use the OnClientClick and UseSubmitBehavior properties of the button control. There are other methods, involving code on the server side to add attributes, but I think the simplicity of doing it this way is much more attractive:

<asp:Button runat="server" ID="BtnSubmit" 
OnClientClick="this.disabled = true; this.value = 'Submitting...';"
UseSubmitBehavior="false"
OnClick="BtnSubmit_Click"
Text="Submit Me!" />

OnClientClick allows you to add client side OnClick script. In this case, the JavaScript will disable the button element and change its text value to a progress message. When the postback completes, the newly rendered page will revert the button back its initial state without any additional work.

The one pitfall that comes with disabling a submit button on the client side is that it will cancel the browser’s submit, and thus the postback. Setting the UseSubmitBehavior property to false tells .NET to inject the necessary client script to fire the postback anyway, instead of relying on the browser’s form submission behavior. In this case, the code it injects would be:

__doPostBack('BtnSubmit','')

This is added to the end of our OnClientClick code, giving us this rendered HTML:

<input type="button" name="BtnSubmit" 
onclick="this.disabled = true; this.value = 'Submitting...';__doPostBack('BtnSubmit','')"
value="Submit Me!" id="BtnSubmit" />

This gives a nice button disable effect and processing text, while the postback completes.

If you found this but are more interested in an AJAX solution to disable buttons during partial postbacks, check out either Postback Ritalin or CSS style as AJAX progress indicator.