Javascript client side page validation

April 3rd, 2009
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Recently I had a problem with “dead” links in a HTML document that was generated from a software solution we have developed at work. After a lot of research this is a smooth solution to the problem if there’s no server-side solution available (i.e. if you watch a local HTML file in a web browser).

It’s not really anything you should use professionally, but at least it’s a workaround…

This is the script:

<script type=”text/javascript”>
function Exist(url) {
var req = false;
// For Safari, Firefox, and other non-MS browsers
if (window.XMLHttpRequest) {
try {
req = new XMLHttpRequest();
} catch (e) {
req = false;
}
} else if (window.ActiveXObject) {
// For Internet Explorer on Windows
try {
req = new ActiveXObject(”Msxml2.XMLHTTP”);
} catch (e) {
try {
req = new ActiveXObject(”Microsoft.XMLHTTP”);
} catch (e) {
req = false;
}
}
}
var res = ”;
if (req) {
// Synchronous request, wait till we have it all
res = false;
try {
req.open(’GET’, url, false);
req.send(null);
} catch (e) {
res = false;
}
if (req.responseText!=”) { res = true; }
} else {
res = false;
}

if (!res)  { alert(’Page does not exist.’); }
return res;
}
</script>

Call it like this:

<a href=”testpage1.html” onclick=”return Exist(’testpage1.html’);”>

Spotify.com

December 6th, 2008
1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 3.5 out of 5)
Loading ... Loading ...

More or less all the music albums out there for “free”? Impossible? Not really.
Normally I’d never dedicate a news post to this kinda “advertisement”, but this is gonna be an exception.

I’ve recently had the opportunity to test spotify.com out for free (and I’m still using it).

My boss been nagging me about this site from the day he discovered it. I must say it beats all my expectations by far.

There are 3 different types of accounts; Free, Day pass(~€1) and Premium(~10€ / month). The free pass requires an invitation (Which you apply for via their site or from a friend who bought the premium account).

When it comes to the range of music and musicstyles on the site, it would beat most services INCLUDING (illegal) torrent sites. It got a search feature where you can search for the title or the artist. You can make different play lists which you can share with your spotify friends. You’ll even get information and biography on some of the artists/groups.

This site+idea get 10 Mathias outta 10 (i.e. The jackpot).

External link: Spotify.com

The future of FPS gaming

November 29th, 2008
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5 out of 5)
Loading ... Loading ...

This is just too interesting to miss out on.

Fact is that the actual technology behind this is way to simple to ignore. My prediction is that we’ll see some commercial results in the early next year of this product.

We are talking about technology for about €30 and that’s the reason I belive this might actually be a hit.


Head Tracking for Desktop VR Displays using the WiiRemote.

How-to: Disable Vista UAC

November 25th, 2008
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

There one thing in Windows Vista that really gets on my nerves, and that’s those damn popups where you are supposed to confirm certain actions.

Microsoft; There are advanced users out there, not everyone is a newbie. :P

There are a few ways to disable it:

MsConfig

1. Control Panel -> Administrative Tools -> System Configuration -> Tools (tab) -> Scroll down to “Disable UAC: Disable User Account Control” and click “Launch”.

(1a. Alternative way: Start - Run - Type “msconfig” - Tools (tab) … etc)

User account

2. Control Panel -> User Accounts -> Click “Turn User Account Control on or off” -> Uncheck the “Use User Account Control (UAC) to help protect your computer”.

(2a. Alternative way: Click Start -> click on the user picture -> Click “Turn User …”)

Group Policy Editor

3. Start -> Run -> Type: msconfig and press Enter
Navigate to “Computer Configuration -> Windows Settings -> Security Settings -> Local Policies -> Security Options”.

Modify the following User Account Control options:

  • Behavior of the elevation propmt for adm inistrators in Admin Approval Mode = No prompt
  • Detect application installations and prompt for elevation = Disable
  • Run all administrators in Admin Approcal Mode = Disable

The Registry

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System

Change the DWORD value “EnableLUA” to a 0.

Disable Windows File Protection (Part 1)

October 20th, 2008
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

What is WFP?

Why would I still want WFP?

Say you accidentally delete a file in the Windows/System32 folder. Windows will detect this and copy it back from the cache folder.
You can easily test this. Open your Windows folder and find the the file notepad.exe (or any other file for that matter). Rename it to Notepad.bak.
Wait a few seconds and refresh the file contents. You’ll see that it’s back already.

Why wouldn’t I want it?

Well, say something (read Adware, trojan, Virus) does get into one of the protected folders. It’s pretty hard to get rid off, since Windows will be more than helpful to put it back again. Also it uses up about 300 MB’s of HD space (\Windows\System32\Dllcache) and probably it’s using unnecessary CPU cycles/disk access to frequently scan trough these files.

So how do I get rid off it?

Sounds easy, there should be some option in the registry … right?
Should is the keyword. Up to Service Pack 2 there were an option. Microsoft decided to remove it, probably because Viruses and Adware abused it.

How can Windows know files have been changed?

Window monitors file events in the Windows and System32 folder. If it detects a modification of a protected file, it will try to restore it.

Disable the WFP - The ways

There’s this nifty DOS utility called SFC. Using this way doesn’t really disable WFP, but it frees up the space used by it.

Using the command line tool you can do adjust the size of the cache. By setting this really low you force it to not cache any files. However, this will generate a pop up where Windows want you to put in the installation disc for Windows if you rename/delete a file (for example Notepad.exe).

This will set the maximum size of the folder to 0, i.e. more or less disabled.

C:\>sfc /CACHESIZE=0

This will empty the folder of protected files, i.e., reclaim the space it’s hogging.

C:\>sfc /PURGECACHE

Next Part will be more complicated and require some hexediting. That we’ll save for another time. ;)

Show My Network Places as a menu

September 30th, 2008
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5 out of 5)
Loading ... Loading ...

This is somewhat a follow up on the earlier post about customizing the start-menu.

I wanted the My network Places to fold out as you can set the other menus. However the option is missing to do this.

By looking at the other items in the registry (and borrowing some text strings that were missing) I manage to make this script that adds the option.)

(Right-click on the Start-menu, select Properties - Customize - Advanced)

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartMenu\StartPanel\ShowNetPlaces]
“Type”=”group”
“Text”=”@shell32.dll,-30481″
“Bitmap”=”%SystemRoot%\\explorer.exe,100″

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartMenu\StartPanel\ShowNetPlaces\Hide]
“HKeyRoot”=dword:80000001
“Type”=”radio”
“Text”=”@shell32.dll,-30492″
“RegPath”=”Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced”
“ValueName”=”Start_ShowNetPlaces”
“CheckedValue”=dword:00000000
“DefaultValue”=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartMenu\StartPanel\ShowNetPlaces\Menu]
“HKeyRoot”=dword:80000001
“Type”=”radio”
“Text”=”@shell32.dll,-30491″
“RegPath”=”Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced”
“ValueName”=”Start_ShowNetPlaces”
“CheckedValue”=dword:00000002
“DefaultValue”=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartMenu\StartPanel\ShowNetPlaces\Open]
“HKeyRoot”=dword:80000001
“Type”=”radio”
“Text”=”@shell32.dll,-30481″
“RegPath”=”Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced”
“ValueName”=”Start_ShowNetPlaces”
“CheckedValue”=dword:00000001
“DefaultValue”=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartMenu\StartPanel\ShowNetPlaces\Policy]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartMenu\StartPanel\ShowNetPlaces\Policy\NoStartMenuNetworkPlaces]
@=”"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartMenu\StartPanel\ShowNetPlaces\Policy\{20D04FE0-3AEA-1069-A2D8-08002B30309D}]
“RegKey”=”Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\NonEnum”

Or as a downloadable script:

  ShowMyNetworkPlaces.reg (3.6 KiB, 259 hits)

Advanced customizing the start menu

September 29th, 2008
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Ever tried to add stuff to the start menu?
Normally it’s not a problem if you stick to the areas where you can do it.

But what if we wanna add links or documents to the other areas?

This is where it starts to get complicated.

This example shows you how to add an item below the “Run” command.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\CLSID\{2559a1f6-21d7-11d4-bdaf-00c04f60b9f0}]
@=”Google”
“InfoTip”=”Google search the web”

[HKEY_CLASSES_ROOT\CLSID\{2559a1f6-21d7-11d4-bdaf-00c04f60b9f0}\DefaultIcon]
@=”%SystemRoot%\\system32\\SHELL32.dll,108″

[HKEY_CLASSES_ROOT\CLSID\{2559a1f6-21d7-11d4-bdaf-00c04f60b9f0}\Instance\InitPropertyBag]
“method”=”ShellExecute”
“Command”=”Google”
“Param1″=”http://www.google.com”

This example shows you how to modify the “Set program access…” item, to something useful, between the Control Panel and Printers.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\CLSID\{2559a1f7-21d7-11d4-bdaf-00c04f60b9f0}]
@=”My Videos”
“LocalizedString”=”My Videos”
“InfoTip”=”My Videos”

[HKEY_CLASSES_ROOT\CLSID\{2559a1f7-21d7-11d4-bdaf-00c04f60b9f0}\Instance\InitPropertyBag]
“CLSID”=”{13709620-C279-11CE-A49E-444553540000}”
“command”=”My videos”
“method”=”ShellExecute”
“Param1″=”C:\\Documents and Settings\\Username\\My documents\\My Videos”
“Param2″=-

Note: You need to change the “Username” to the real thing.

As for adding/changing the links around “My documents” and that, there’s no solution afaik. Maybe I’ll have to come back to that in the future.

Happy registry modifying. :)

VLC v0.9.x and MCE remote

September 25th, 2008
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 4 out of 5)
Loading ... Loading ...

So, they finally decided to release the long awaited v0.9 of the VLC player.

> http://www.videolan.org/ <

Anyways, since they change the caption around on the VLC window, I had to make a smaller modification for the MCEVLC to be able to find the correct window.

Changes:

* I’ve added the “Send to active window” option in case VLC will be active all the time.
* The Window-name supports a partial match now, so the phrase in the picture above would find the window labeled  “Mymovie.avi - Mediaspelaren VLC”. This is obviously something else in, for example, English.

There’s also some bugfixes in this release + some started on features (as in mouse-pointer moving, clicking etc)

And finally, no, there’s still no documentation whatsoever ;)

  MCEVLCv1.1.3-setup.exe (652.5 KiB, 771 hits)

Direct download link to the replacement drivers: http://burningzeroad.free.fr/MceIrApi.rar

Right-click image to add folder.jpg

September 19th, 2008
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5 out of 5)
Loading ... Loading ...

This occurred to me when I was sitting and ripping and downloading album art for some Cd’s I had.
There were no really easy way of adding a folder album art picture. Since I’m not all that stupid (most of the time anyways :)), this is how I solved it.

Part 1

  fixfolderjpg.cmd (97 bytes, 221 hits)

The “fixfolderjpg.cmd” file:

@echo off
copy %1 “%~dp1folder.jpg”
attrib -s -h thumbs.db
del thumbs.db

Optional line:

attrib +h folder.jpg

Explanation of the script:
Line 1: @echo off -> We don’t wanna see the echo:ed commands
Line 2: Copy the selected file to folder.jpg in the same folder.
Line 3+4: Take away the System and Hidden attribute on the thumbs.db file and delete it. This is to make sure the folder image gets updated asap.
Line 5: Hide the folder.jpg file

Part 2

  folderart.reg (436 bytes, 224 hits)

The Registry hack:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\jpegfile\shell\albumart]
@=”Use as Folder art”

[HKEY_CLASSES_ROOT\jpegfile\shell\albumart\command]
@=”C:\\Windows\\System32\\fixfolderjpg.cmd \”%1\”"

Explanation: More or less adds the “Use as Folder art” to the contextmenu when you right-click a JPG file. Note the path that might needed to be altered if you save/create the script in some other folder.

Happy folder decorating ;)

Uncompress a compressed NTFS drive

September 18th, 2008
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Right, so you ran out of disk space. That cleanup dialog flashed by and you accidently compress the whole of your C: drive. Not only will it generally slow down your computer quite a lot, it will also make the files way harder to recover in case of, for example, a hard drive crash. And finally the compression won’t do you any good if you are trying to compress MP3’s and AVI’s, since they are already compressed as they are.

Ok, so how do I fix it?

One way is to open the C: drive from explorer, select all files and folders, right-click and go into properties - advanced and uncheck “Compress files to save disk space”.

However, not only will it take forever to do from Windows, but it might also possible mean trouble if you accidentally select some other attribute while doing this. And finally, if some error occur during the decompressing it will interrupt it and prompt you what to do.

So what’s the easy way?

Use the command line prompt (aka DOS prompt).
The Compact.exe will do the task for you.

COMPACT: Displays or alters the compression of files on NTFS partitions.

COMPACT [/C | /U] [/S[:dir]] [/A] [/I] [/F] [/Q] [filename [...]]

/C Compresses the specified files. Directories will be marked so that files added afterward will be compressed.

/U Uncompresses the specified files. Directories will be marked so that files added afterward will not be compressed.

/S Performs the specified operation on files in the given directory and all subdirectories. Default “dir” is the current directory.

/A Displays files with the hidden or system attributes. These files are omitted by default.

/I Continues performing the specified operation even after errors have occurred. By default, COMPACT stops when an error is encountered.

/F Forces the compress operation on all specified files, even those which are already compressed. Already-compressed files are skipped by default.

/Q Reports only the most essential information.

filename Specifies a pattern, file, or directory.

Used without parameters, COMPACT displays the compression state of the current directory and any files it contains.You may use multiple filenames and wildcards. You must put spaces between multiple parameters.

What you do is simply to type to decompress the whole drive:

compact C:\*.* /U /I /S

This will Uncompress, Ignore all errors and include all Sub directories.

If you are running out of diskspace, buy a new hard drive. ;)