Wednesday, September 23, 2009

python: writing your own urllib2 redirect_handler

class SmartRedirectHandler(urllib2.HTTPRedirectHandler):

    def redirect_request(self, req, fp, code, msg, headers, newurl=''):
        global intermediateURL
        intermediateURL = newurl

        if code in (301, 302, 303, "refresh") or (code == 307 and not req.has_data()):
            newRequest = urllib2.Request(   
                                            newurl,
                                            headers=req.headers,
                                            origin_req_host=req.get_origin_req_host(),
                                            unverifiable=True
                                        )
            newRequest._origin_req = getattr(req, "_origin_req", req)
            
        return newRequest
        
        else:
            raise HTTPError(req.get_full_url(), code, msg, headers, fp)

source

Tuesday, September 15, 2009

how to enable tap zones on dell mouse drivers

To unlock the native touchpad features which are masked by Dell's touchpad software:

1. Go to control panel and select MOUSE to see what options are available (very few) and close that all up.

2. Next click on the Windows Start icon and type regedit in the search box.
Windows Registry will open.

Navigate to HKEY_LOCALMACHINE\SOFTWARE\Alps\Apoint and look for the key UseCustomGUI (it's the 2nd to last entry on the list)

Change the value from 1 to 0 and click on OK

3. Next minimize the registry (don't close it yet).
Goto Control Panel and select MOUSE.
Now all the ALPs settings are unlocked and appear here.

For example the GESTURES feature is now showing.
Select GESTURES tab and check ON the box for
Use Back/Forward Buttons.
Then click APPLY and OK.
Close the Mouse settings and close the Control panel.

4. Now go back to your registry setting and change
UseCustomGUI back to it's original value of 1 and close it and the reg editor.

Everything is back exactly as it was but the feature remains enabled.

All done....now when your surfing just swipe your finger along the top edge of the touch pad to go back and forward.


source

Monday, September 14, 2009

vbscript: create system restore points with no fuss

Here's how to create a simple VBscript that will create a restore point when you double-click it:

1. Save the code below to, say, c:\system_restore.vbs:

Set SRP = GetObject( "winmgmts:\\.\root\default:Systemrestore" )
CSRP = SRP.CreateRestorePoint( "Before Changes", 0, 100 )

2. Double-click the script file you just created, any time you want to create a fresh System Restore Point.

It only takes a few seconds to do this. And no dialogues are shown to confirm that a Restore Point was created. If you want to double-check you can click "Start | All Programs | Accessories | System Tools | System Restore" and click "Restore My Computer To An Earlier Time."

You'll see the restore point you just created (called "Before Changes") right there. Now be sure to cancel out of System Restore.

source