How to Create a Google Map from GPS coordinates

No Comments

You can import coordinates into Google Maps using the KML or GeoRSS formats.

Here’s how you do it in five easy steps:

1. Have your coordinates ready, in a text file, Excel, csv file, on paper etc.

2. Download a csv/text/Excel to KML converter. I used this one by simon_a and it worked like a charm. It is all in Excel so you don’t need to install anything. Check the three tabs in the file, you need to:

a) On Tab 1, enter your longitude and latitude coordinates (copy and paste or use import data from your existing coordinates file) In the example coordinates are on a format with comma (,) I needed to change these to use dot (.) to make the import to Google Maps work. (just do search and replace, ctrl+h)

b) Set the output file name on tab 2

c) Make sure Excel security settings allow you to run the macro. Press Alt+F8 to run the Generate KML macro. It does not tell you when it’s ready but it runs real quick.

3. Go to Google Maps – http://maps.google.com Make sure you sign in so you can save your new map.

4. Create a new map and select Import to import your .kml file

5. Done!


View Fordonsgas, Biogas tankställen (CNG in Sweden) in a larger map

I have a biogas (CNG) car and it’s always a hassle to find a place to fill it up. There is a public site that let’s you download coordinates for your GPS but they don’t provide anything but that .csv file and a pdf to print. Now I finally have it imported into so I can access from my cellphone with Google Maps and GPS. Wish I would have done this a couple of years ago…

Here it is if you should ever need some biogas in Sweden :)

ASP.NET 4.0 Chart Control Problems on IIS7

1 Comment

I have been playing around with the ASP.NET 4.0 Chart Controls for a new web site (Bilvärdet.se – used car price statistics)

When deploying it to IIS7 on my Windows Server 2008 I ran in to a few problems:

1) I did not have .NET 4.0 Framework installed on the server

:) It turns out .NET 4.0 Framework is an optional update in Windows Update and for some reason that I could not figure out failed to install (error code: 80200053) Solution that worked: Manually installed it. I had to use a tool that was new to me, the Microsoft Web Platform Installer (Web PI). Seems to be a cool tool to download, install and configure all sorts of software (incl Wordpress, Dupral, Joomla) on Windows, will check this out in more detail in the future.
Don’t forget to change the Application Pool for your Web Site/Web Application in IIS Manager to use .NET Framework 4.0

2) Next problem, error message: An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode

This turned out to be a few lines of code in web.config that seems to be needed on my development machine (Windows7 and Visual Studio 2010) but causes problems on IIS7.

Just removed this section from production web.config on server and it worked:

<httpHandlers>
     <add path="ChartImg.axd" verb="GET,HEAD,POST"
     type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler,
     System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral,
     PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers> 

Thanks to Michael Narinsky for pointing this out.

3) Image file directory problems

First error message: Invalid temp directory in chart handler configuration c:\TempImageFiles\

Solution: Changed dir in ChartImageHandler app settings in web.config

<appSettings>
     <add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;"/>
</appSettings> 

Then this error message: The temp directory in chart handler configuration is not accessible c:\xxx\images\

Followed error message suggestion and added access rights to directory (Properties – Security tab) for user NETWORK SERVICE

4) Charts not rendering with ASP.NET Routing

I’m using ASP.NET 4.0 Routing but this seems to be something Charts are not working well with. Charts are showing up as broken links. If you are using routing, you need to make sure ChartImg.axd is ignored. Add Ignore (or IgnoreRoute) and – this took me quite some time to figure out – make sure you add these before any MapPageRoute or it will not work!

This is what I added in VB.NET, add one line per level in virtual/route folder structure – first line is for root, second line for one subdirectory level, third line for two subdirectory levels.

routes.Ignore("ChartImg.axd/{*pathInfo}")
routes.Ignore("{controller}/ChartImg.axd/{*pathInfo}")
routes.Ignore("{controller}/{action}/ChartImg.axd/{*pathInfo}")

Thanks to Simon Steele.

BTW – Another nice link about ASP.NET Chart Control

MySQL and Visual Studio 2010 Membership, Roles and User Profile Provider

1 Comment

In Visual Studio 2010 (VS2010) when you create a new Web Application Project using the default Web Template “ASP.NET Web Application” it creates an Account folder with the files Login.aspx, Register.aspx and ChangePassword.aspx.
These are files/pages for ASP.NET Membership which is ASP.NET’s built-in user handling. I have never used Membership before but have been curious to, so I saw this as my cue to do so. However since I’m running MySQL as my database server I knew I had some extra installing and configuring to do.

Now several hours later I have finally figured out what I needed to do…

1) Install the latest version of MySQL Connector/NET. Visual Studio support is from version 6.3 which is currently only available in beta, current version when writing this is 6.3.2 beta.

2) Use the MySQL Website Configuration Tool, follow instructions found by clicking this link. This tool will modify necessary configuration files (have not checked which, maybe only web.config) to use MySQL Membership, Roles, User Profile and/or Session State.

Important: (this took me quite some time to figure out) the MySQL Website Configuration Tool icon only shows up in the Solution Explorer if you create a Web Site Project in VS 2010. It does not show if you create a Web Application Project. I have reported this as a bug to MySQL.

The only workaround I found to use a Web Application instead of using a Web Site was to create a temp Web Site project, run the MySQL Web Configuration Tool and then use copy and paste to move changes from web.confg to my Web Application Project. I have provided these changes at the end of this post.

3) Done!

I am running Windows 7 64-bit, Visual Studio 2010 and MySQL Connector/NET 6.3.2 beta, but according to this thread other people with other versions of VS seems to be having the same problem.

These are the changes that are made to web.config:

  <connectionStrings>
    <remove name="LocalMySqlServer" />
    <add name="LocalMySqlServer" connectionString="server=localhost;User Id=root;database=users;password=xxx" providerName="MySql.Data.MySqlClient" />
  </connectionStrings>
<system.web>
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
    </authentication>
    <membership defaultProvider="MySQLMembershipProvider">
      <providers>
      <clear />
      <remove name="MySQLMembershipProvider" />
        <add name="MySQLMembershipProvider" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.3.2.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" applicationName="/" description="MySQL default application" connectionStringName="LocalMySqlServer" writeExceptionsToEventLog="True" autogenerateschema="True" enablePasswordRetrieval="True" enablePasswordReset="True" requiresQuestionAndAnswer="False" requiresUniqueEmail="False" passwordFormat="Clear" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression="" />
      </providers>
    </membership>
    <profile defaultProvider="MySQLProfileProvider">
      <providers>
        <clear />
        <remove name="MySQLProfileProvider" />
        <add name="MySQLProfileProvider" type="MySql.Web.Profile.MySQLProfileProvider, MySql.Web, Version=6.3.2.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" applicationName="/" description="" connectionStringName="LocalMySqlServer" writeExceptionsToEventLog="False" autogenerateschema="True" />
      </providers>
    </profile>
    <roleManager enabled="false" defaultProvider="MySQLRoleProvider">
      <providers>
        <clear />
        <remove name="MySQLRoleProvider" />
        <add name="MySQLRoleProvider" type="MySql.Web.Security.MySQLRoleProvider, MySql.Web, Version=6.3.2.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" applicationName="/" description="" connectionStringName="LocalMySqlServer" writeExceptionsToEventLog="True" autogenerateschema="True" />
      </providers>
    </roleManager>
  </system.web>

Install cURL PHP Extension on Windows IIS

No Comments

I tried to run a new PHP script that someone else wrote for me on my Windows Server 2008 and got some errors relating to cURL such as this:

Fatal error: Call to undefined function curl_multi_init()

First I spent a lot of time trying to find information on how to install cURL on a Windows IIS installation, downloaded the cURL package, moved around files, copied to c:\windows\system32, updated php.ini and did all sorts of things described in forums, blogs and manuals but could not get it to work.

Finally I decided to upgrade my PHP from 5.3.1 to the latest 5.3.2 release. I downloaded the PHP Windows MSI installer and there in the Setup Wizard you can simply select what extensions you want to install. Selected cURL and it worked like a charm :) I guess it was just to easy…

(I post about this not only to let everyone know how stupid I am but since I could not find this info anywhere it could be good to document it)

I also tried running the installer again in “Change” mode to add and remove Extensions and the installer seems to be doing a pretty good job at adding and removing files + updating php.ini the way you would expect it to.

At one point I tried installing all Extensions but that got me in to trouble giving me a “oci.dll not found” trying to load an Oracle dll. My tip here is to install only the extensions you need or at least not any related to databases you do not use.

After clicking “Next” when you have selected what Extensions to install, the setup wizard may tell you files are locked and you have to restart the server after installing. A way to avoid this can be to (before clicking “Next”) stop the World Wide Web Publishing Service (from command line: NET STOP W3SVC). Just remember to start it again after!

Extensions available from install package in 5.3.2
bzip2
Curl
Enchant
EXIF
Fileinfo
GD2
Gettext
GMP
IMAP
Internationalization (intl)
LDAP
Multi-Byte String
MySQL
MySQLi
OpenSSL
Oracle (10)
Oracle (11g)
PDO
PostgreSQL
Shared Memory
SNMP
SOAP
Sockets
SQLite
SQLite 3
Tidy
XML-RPC
XSL

MySQL Workbench Query Browser is super slow

1 Comment

MySQL GUI Tools which included the MySQL Query Browser and MySQL Administrator has now been replaced by the MySQL Workbench tool.

The Workbench edition which includes Query Browser (now called SQL Development) and Administrator (now called Server Administration) is only available in beta but it the old MySQL GUI Tools have already been pulled from Downloads. So I downloaded the latest beta version of MySQL Workbench 5.2.20 and gave it a try.

I’m sorry to say I was very disappointed.

This is what I have found using the SQL Development part (former Query Browser)

  1. It is super slow. Doing a query that usually takes a second in the old Query Browser can take minutes! These are just simple queries and it seems the time is not the query itself or time to fetch from server that makes it slow. This alone makes it impossible to use this tool.
  2. It is not intuitive. I find it hard to work with, maybe it just takes getting used to
  3. Features and functions from the Query Browser are gone, for example in Query Browser it was possible to open up a new tab to run a new query, you could then switch between tabs to see the different results. In the new SQL Development you can open up new query tabs but there is only one results tab. Another thing is that it does not show how many rows were affected by your query. Yet another missing feature is the ease to edit a row, in the old Query Browser all you did was click the Edit button. In the new SQL Development you have to do a specific “EDIT” query (which is even slower than the super slow SELECT) and then go thru several “ok” screens before your edit is finally written to database. I’m also missing is the system Tray Monitor and the Migration Toolkit.

I know it’s only a beta so hopefully they will get these things working in the end but for now I’m going to stick to the old Query Browser.

After some searching I found the old GUI Tools in the MySQL Download Archives.
It seems the latest/last version of GUI Tools was 5.1.12 and can be downloaded here.

Wordpress on Windows/IIS cannot upgrade, add plugins, upload themes

2 Comments

I have been struggling with this one ever since I moved my Wordpress installation from my old Windows 2003 server to a new Windows Server 2008 machine. If I try to use “automatic upgrade” to upgrade to the latest Wordpress release or upgrade or add a new plugin I get to the “Connection Information” page asking me to fill out ftp host name, user name and password. When I try to upload a new Wordpress theme I get 500 Internal Server Error. I have understood that this is a permissions problem in the file system but have failed to be able to solve it.
I have been trying to give various users and groups permissions on the everything from the entire wordpress directory to the wp-content folder.

However what I did not realize until today is that (at least in my Windows installation) the group IIS_IUSRS does not have any group members but I should instead give the user IUSR permissions. Too easy… :)
So simply do this: give user IUSR Modify and Write permissions to your Wordpress directory.

Finally!

PHP 5.3.1 upgrade on IIS7 and MySQL gives Internal Server Error

3 Comments

Solution

After a lot of googling and testing I finally found Bruce Kirkpatrick’s comment at the end of the PHP install manual

Seems it is no longer enough to have localhost in the servers local hosts file (C:\Windows\System32\drivers\etc\hosts) you also have to comment out or remove the IPv6 equivalent.

127.0.0.1 localhost
#::1 localhost

After I did this everything worked ok again. Thanks Bruce!

Problem

I just upgraded PHP on my Windows Server 2008 running IIS7 from PHP 5.2.10 to 5.3.1. Used the non-threaded install package and installed for FastCGI.

After the upgrade installation worked fine for some non-database driven pages and phpinfo worked fine but whenever a page tries to accessed the MySQL database the browser only gave me a 500 Internal Server Error.

Checking the php error log (C:\Windows\Temp\php-errors.log) I get messages like this:

[24-Feb-2010 13:44:36] PHP Warning: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in C:\inetpub\wwwroot\XXX\init_page.inc on line 32
[24-Feb-2010 13:44:36] PHP Warning: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
in C:\inetpub\wwwroot\XXX\init_page.inc on line 32
[24-Feb-2010 13:44:36] PHP Fatal error: Maximum execution time of 60 seconds exceeded in C:\inetpub\wwwroot\XXX\init_page.inc on line 32

Hide Empty Rich Text Field in Lotus Notes

No Comments

The problem is very simple: I want to hide a Rich Text field (RTF) if it is empty and show it if it has something in it, in my case one or more attachments. In Lotus Notes a Rich Text Field will not evaluate to empty even if it is emtpy so using a common Hide-When forumula such as MyRTF=”" will not work and you can only use @Formulas.

The solution:

1) Create a new Numeric field, Computed for Display, Hidden, and with Value set to @ThisValue (or HideMyRTF if you are using an earlier release than ND6)  Lets call this field HideMyRTF in this example.

2) Set the Hide-When formula of your existing Rich Text Field – lets call it MyRTF in this example – simply to HideMyRTF (meaning if HideMyRTF is True then hide MyRTF)

3) Add some LotusScript using the NotesRichTextItem EmbeddedObjects property to the Forms QueryOpen event. This will check if there are attachments or text in the field:

Dim rtitem As NotesRichTextItem
Set rtitem = source.Document.GetFirstItem( "MyRTF" )
If Isempty(rtitem.EmbeddedObjects) And Trim(rtitem.Text) = "" Then
    source.Document.HideMyRTF = 1
Else
    source.Document.HideMyRTF = 0
End If

That’s it.

It was a long time since I did any Lotus Notes development so I’m a bit rusty. I’m sure I’ve come up with this or a similar solution in the past but I could not find any when searching so I had to start from the beginning.

This was for an existing app that has been around for quite a few years so there is no way for me to control anything from the beginning. I guess I could have used an agent to set some stuff but this would most likely cause tons of replication conflicts as there are tens of thousands of documents, still being updated by users and replicated across several servers.

Done with a Lotus Notes 7.02 client (I told you it’s been a while…) but should work on older and newer releases.

Facebook Share Button in Frameset

2 Comments

I spent a lot of time today figuring out how to get the Facebook Share Button to work in a frameset and display the frameset Url and Title instead of the Url and Title of the frame the button was placed in. I thought this should be very easy but it took me quite some time to fnd an ok solution, probably because I’m not that good at Javascript. If you know of a better solution please let me know.

Facebook Share Button original code:

<a name=”fb_share” type=”icon_link” href=”http://www.facebook.com/sharer.php”>Share</a>
<script src=”http://static.ak.fbcdn.net/connect.php/js/FB.Share” type=”text/javascript”></script>

To set url and page title to that of frameset add this after above code:

<script>
document.getElementsByName(‘fb_share’)[0].setAttribute(‘href’, ‘http://www.facebook.com/sharer.php?u=’ + escape(parent.location.href) + ‘&t=’ + escape(parent.document.title));
</script>

One problem with directing Facebook direct to the frameset url is that it cannot find Content Summary and Image but I think this can be fixed by adding some meta tags as described in Facebooks documentation.

Get a Google Wave invite

98 Comments

I have been trying out Google Wave for a few days now and I have to say that I’m not that impressed with the user experience – it is not at all inutitive, this is obviously the type of program where you really have to read the manual! But I will give it some more time, read that manual, watch the instruction videos etc.

Anyway, I have some Google Wave invites so if you’re interested just comment here with your email and I will give away on a first come first serve basis.

Ps. I’m looking for a Voddler invite, anyone got one?

[Edit: I'm out of invites. Will post here again if I get new ones]

Older Entries