3. Dec 2009

How a non-tech-savvy user can use the Statkart resources

Statkart.no recently released their map data for free usage (at least to a certain degree) – but how can non-tech-savvy users / non-webdevelopers use this?
I’ll try to post some suggestions here – first out is

Swap to more interesting map data on Dagbladet a lot of sites with Google Maps:

Added autodetection – sites with a Google map (GMap2) stored in a globally accessible variable named map or gMap should “just work”.
For the non-tech-savvy: Try clicking the bookmarks while on a page that has a map with the Google logo on it – it might just work! :-)

Note: The links below currently violates the terms of usage as they do not add the proper copyright notice under maps.
This can be solved with some more javascript (inject a div under the map, for instance), I’ll see if I’m able to do so later.

Add the following links as bookmarks and you should (at least in Firefox, Chrome and IE8) be able to swap maps while on an article with a Google map @ db.no.
ProTip: Add a new folder to your bookmark toolbar (or Favorites bar in IE) and store them all in there – that way they’re easily accessible.

Kartdata2

Sjøkart

Topografisk kart

Topografisk kart gråtone

Topografisk rasterkart

Europakart

Post to Twitter

2. Jun 2009

Adobe Creative Suite 2 and Windows 7 (64bit)

Ever since the Windows 7 RC came out I’ve been testing it at work, and to my great surprise most of the software I run on a daily basis just works. Netbeans, Tortoise, WAMP, they all work as expected. I had not, however, even dared to try Adobe Creative Suite 2 as I’ve heard people complaining about lousy compatibility even under Vista. It all changed today!

I’ve spent the last month with Photoshop/Illustrator only available on my tiny Macbook Air, and I grew tired of it eventually. Since I felt really lucky today I decided to go be an idiot and try to get CS2 up and running in Windows 7 :-)

During the setup my first problem occured – invalid path name. I’m running Windows 7 64bit and it automatically puts 32bit applications in the Programfiles (x86) folder. The CS2 setup wasn’t too happy about it so I changed it to the regular path, C:\Programfiles. CS2 installed as expected – awesome I thought!

I expected Photoshop to keep nagging me about registration over and over again until I ran it as administrator, similar to the problem under Vista. But nay, Photoshop gave me a short error about “user name, organization, or serial number is missing or invalid” meaning it had to terminate without me painting a single pixel. After some research I found that this was a problem that would occur under 64bit versions of Windows XP as well – and the solution for Windows XP 64bit users worked for me!

According to Adobe, you have to get your Creative Suite installation into that x86 directory, and here’s how to do it:

Uninstall Creative Suite completely, when installing again use C:\Progra~2\Adobe as your installation path instead of the one suggested. If your “Next” button is disabled after pasting it, try clicking “Browse” then “Cancel” and it should be reenabled.

I’d also like to point out that I ran my setup as Administrator (browsed to the DVD drive then right clicked setup.exe and chose (“Run as Administrator”) the second time just to be sure.

It worked out quite well actually, hooray!

Post to Twitter

16. Dec 2008

C#: Implementing IComparer for FileInfo objects (for binary searching and sorting)

While coding a thingie in C# that will optimize Acrobat Reader automatically I came across the need for interal overriding. More specifically I wanted to do a List.BinarySearch and my List was filled with FileInfo objects. Since one can compare files (for sorting and searching) in so many ways, you’re left on your own to subclass / override with the interface IComparer.

I found a neat example at http://www.mattandchristy.com/post/2008/02/Custom-Sorting-In-C-Sharp.aspx that shows just how easy it is to implement a custom IComparer.

My solution:


internal class PathCompare : IComparer
{
public int Compare(FileInfo o1, FileInfo o2)
{
return o1.FullName.CompareTo(o2.FullName);
}
}

Of course, this could be changed if you wanted to compare bytes, dates or whatever. My binary search was then executed like this:


myList.BinarySearch(myFile, new PathCompare());

Hooray!

Post to Twitter

9. Dec 2008

Distribute Windows XP VPN-settings

As our Oslo branch has been gradually shut down, we now have very few (but some) users left in Oslo. Our office there has always been connected to the branch in Fredrikstad where all our servers reside trough a Firewall level VPN link making connections across the two subnets pretty transparent. Since so few users are left in Oslo however, we’ve decided to cancel the inet line subcription and connect them to sister companies in the same building, where other policies apply and a bridge between networks is out of the question.

We’ve had a VPN available for users working remotely for quite some time already, thanks to our beloved Dlink DFL-800’s. The challenge now was that we’d like to make the transition to client-based VPN links as easy and invisible for our users as possible.

Our Windows XP VPN-configuration required several custom, non-standard settings (such as no ‘Use default gateway on remote network’) in order to work, and we couldn’t expect our users to know these things. Most sysadmins tend to create a frustratingly long guide with lots of screenshots to make sure the user will set up a connection properly, but these are easily too complex and all in all pretty demotivating for the average user. Creating such a guide was not an option for us as it would ruin our goal all by itself; make the transition almost invisible to users.

Hoping that I could find a way to export these settings, then distribute them to our users, I googled and googled. I couldn’t find a good way to do this from the command line either (you do have rasdial, but it didn’t cover nearly all my needs).

After a lot of searching I came across some forum post (my apologies to the author of it for losing the URL) about a file called rasphone.pbk. And yes, this was what I was looking for, indeed. That’s where all the magic is stored!

So, here goes, “How to distribute VPN-settings to multiple users”:

As mentioned, the file we’re looking for is called rasphone.pbk and can be found in C:\Documents and Settings\All Users\Application Data\Microsoft\Network\Connections\Pbk by default on a Windows XP English install.

Each VPN-connection has a pretty long entry in this file, so it’s important that you copy the file out, open your fresh copy in a texteditor and edit out all other connections. Username, password and domain is not stored in this file, so no need to worry about clearing it!

VPN-connections are identified by [ ] around their name, and all lines until the next name between [ ] belongs to that VPN-connection. When you’ve edited out all other connections you can in fact distribute this file to others. When they double-click it they will be able to load VPN-settings on the fly.

Problem solved one might think, but no. Windows XP will not add this information to connections, so it’s not a persistent solution. My take on this was that I’d have to append my .pbk-file to the existing one. This was accomplished with a neat little bat-file:


echo. >> "%allusersprofile%\Application Data\Microsoft\Network\Connections\Pbk\rasphone.pbk"
type YourVeryOwn.pbk >> "%allusersprofile%\Application Data\Microsoft\Network\Connections\Pbk\rasphone.pbk"

The first echo puts in a newline to make sure we’re moving onto a separate line.
The second command, type, works pretty much like cat under linux; it catenates the given file to standard output. We then append this to rasphone.pbk with >>.

Please note that I use %allusersprofile% here, as you do not have an environment variable available that goes directly to the Application Data directory of All users (you have %appdata% for regular users). This prevents your bat from working under localized versions of XP. My solution for this was to create another bat for those who run a Norwegian version of XP.

Another note: after the bat has been run you’ll have to right click and select Refresh in your Network Connections overview for the new connection to appear. Once this has been done it’ll be available as any ordinary created VPN-connection.

I’ve began looking at Nullsoft Scriptable Install System (NSIS) to ensure Vista support and automate it further; localization will not be a problem there as you have $APPDATA depending on your ShellVarContext. I’ll most certainly publish my NSIS source code here if I decide to go down that approach.

In addition to appending VPN-settings I also encountered a problem with our internal DNS not being available, so our mailserver and more would not be available for Outlook once the DNS cache had been flushed. This wasn’t much of a problem tho, I just threw in some extra lines in my bat that appends necessary DNS overrides in Windows’ hosts-file:


echo. >> "%systemroot%\system32\drivers\etc\hosts"
echo #### MyCompany Mailserver #### >> "%systemroot%\system32\drivers\etc\hosts"
echo 10.0.0.1 mailserver >> "%systemroot%\system32\drivers\etc\hosts"
echo 10.0.0.1 mailserver.domain.local >> "%systemroot%\system32\drivers\etc\hosts"

Have a blast distributing VPN-settings!

Post to Twitter

20. Nov 2008

Optimizing Adobe Acrobat Reader 8/9 in 10 seconds on Windows XP

I’ve seen some posts about disabling plugins in Adobe Acrobat Reader in order to boost it well into pdf-heaven, but there are several solutions floating around on the web. I thought I’d sum up what I consider the best way to make the reader very fast while still keeping the functionality. And if you’re fast it can be done in less than 10 seconds!

As we’re currently designing a new system image for all our machines and therefore have a test group, I was fortunate to get some user feedback on this method. They were all positive once I had the right files in the right place.

So, here goes (make sure Adobe Acrobat Reader is NOT running while doing this):

  1. Navigate to your Adobe Acrobat Reader installation directory as a user with Administrative rights.
    The default path is %programfiles%\Adobe\Reader 8.0\Reader\ or  %programfiles%\Adobe\Reader 9.0\Reader\ depending on your version
    To go there quick, presuming you’ve kept the default directory, hit Windows button + R and enter the default path given above, then hit Enter.
  2. Go into the plug_ins (retarded name btw) directory, hit Ctrl + A to select all files and Ctrl + X to cut them to your clipboard
  3. Go up/back to the installation directory and enter the “Optional” directory. Paste the files here with Ctrl + V.
  4. While holding Ctrl click on the following files:
    • AcroForm.api
    • EScript.api
    • IA32.api
  5. Hit Ctrl + X to cut these, go back to the plug_ins directory and hit Ctrl + V to paste them back where they once were.

Voila!

Your Adobe Acrobat Reader should now open PDFs as fast as Preview in OS X or Ghostview in Windows / Linux.

There are a couple of remarks here:

  • By putting all files into the Optional folder these plugins (e.g. text2speech) will not be loaded when Acrobat Reader is started. They will instead be loaded when explicitly asked for / needed.
  • Why did I move some files back you might ask yourself? Well, without these files you won’t be able to load Acrobat Reader in a browser window without the browser going bananas.

While some users (probably 3 in the whole world) might need all those plugins immediately we quickly realized that our average user does not.

This trick, in part, is possible in earlier versions of Acrobat Reader as well, but the older it gets, the less plugins it has, so.. :-)

Post to Twitter

3. Nov 2008

Windows update not working after SP3

So, a while back, more specifically when Microsoft pushed XP Service Pack 3 onto Windows Update we started experiencing some problems. After SP 3 had been sucessfully installed, all attempts to update via Windows Update failed. A couple of friends that works in other organizations reported the same problems.

After some extensive research I found out that Microsoft had upgraded Windows Update in SP 3, which to me seemed like a plausible source of the problem.

I checked my version only to find that I ran the old one; something wasn’t right. So, after deep diving into my %systemroot%\system32\ folder I spotted the dll file for the new version, wups2.dll. Since it had not been loaded properly I decided to engage in some trial and failure.

Suspecting that the installation of Windows Update 2 had failed at some point I took a shot in the dark and tried to register the dll so Windows would reckognize it. And voila, it worked!

I am aware that there are fixes available from Microsoft for this issue, but if you’d like to save yourself some time try this little hack (it requires administrative rights on the machine you’re fixing):

Hit start, run and type cmd to bring up a command line prompt.

First you’ll have to stop the Windows Update service. Type “net stop wuauserv” and press enter.
Second, and this is the magic, register wusp2.dll. Type “regsvr32 %systemroot%\system32\wups2.dll” and press enter.
If all goes well you’ll now be able to restart Windows Update with “net start wuauserv”.

Hooray!

Post to Twitter