Thursday, December 17, 2009

YQL, Pipes and beyond

I've recently fallen in love with Yahoo again

Inspired by Haayman (a runsat user) I've been using Yahoo pipes to manipulate the site RSS output into more human friendly form.

The latest bit of this is here: http://pipes.yahoo.com/runsaturday/osmfeed -


Inspired by http://blog.pipes.yahoo.net/2009/06/01/using-yql-execute-to-power-the-pipes-webservice-module/ this pipe just shows how developed the web is now...

- it gets data from runsat
- processes that data
- makes a call to YQL which then processes the data through this serverside javascript - http://www.slodge.com/yql/pipe5.xml (this converts a google maps API
- processes the data some more
- spits out some new RSS which can then be consumed by web pages - e.g. by http://hollybar.blogspot.com

Of course, all of this could also be seen as fragile - it relies on external web services, but these are all on Yahoo! - so not too fragile (I hope!).

The programmable web - I love it!

Sunday, December 13, 2009

More player code live on runsaturday

A "simple" player:









A player with side map and elevation/speed chart:



Tuesday, November 17, 2009

"The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel."

If you're working late at night and suddenly you start seeing lots of https issues concerning... "The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel."

Then it might just be because your app is routing its requests via the excellent fiddler2 - in which case SSL will not be trusted :)


Monday, November 16, 2009

Hard disk thrashing on Vista

I've been struggling recently with far too much hard disk thrashing.

So I searched around for help, and I've no idea if their advice helps yet, but this article seemed at least well written:
http://bucarotechelp.com/computers/windowsts/95021801.asp?x=62&y=6&page=1

Let's hope it helps - because recently the hard disk action has been way too slow!

Super easy to use (and free) POP3 email client source code

Really good project!
http://www.codeproject.com/KB/IP/Pop3MimeClient.aspx?fid=341657

Super easy to follow walkthrough for creating a custom DNN scheduled task

Super easy to follow walkthrough for creating a custom DNN scheduled task -

Really good stuff

Wednesday, November 11, 2009

Visual Trace Route

Just found this on the web. It wasn't what I was looking for - but it's a cool toy - let's you see some cute tracert maps
http://www.yougetsignal.com/tools/visual-tracert/

Would be fabulous if they could actually use my tracert results rather than their results.

Tuesday, November 10, 2009

JSON and cross site scripting

Been doing quite a lot of JSON work recently.

Have hit the odd occasion where I've needed to get JSON data across domain boundaries.

To do this, the only way seems to be to make use of <script> tags rather than making use of simple (e.g. Jquery) xml/http get's.

Basically what you do is:

1. Define a callback method, e.g.:

function myCallback(data)
{
// do stuff
}

2. On the server, instead of returning JSON, return the JSON inside a callback call, e.g.:
myCallback({ "thing": 12 });

3. To make the ajax call, then add a script tag to the document head:
            var scriptBlock = document.createElement('script');
            scriptBlock.src = jsonUrlToCall;
            scriptBlock.type = 'text/javascript';
            document.getElementsByTagName('head')[0].appendChild(scriptBlock);

4. Actually, that's it!

Tuesday, November 03, 2009

Samsung Omnia 2... GPS - the only setttings that work

More about this another day...

But have wasted so much time on trying to get Samsung Omnia II to hook up to GPS today...

Whatever you do, don't change the default settings:

Go to setting --> General Setting --> GPS --> Connection 
GPS program port: com7
GPS hardware port:com9
Baud rate: 4800
Click on done.
Go to XTRA
Enable XTRA Server
Tick "ZWhen connected to PC via ActiveSync
Enable SNTP Server (Only when you have data plan)
Click done.

These settings work!


Some color code to make some javascript HTML colors darker

I needed to quickly produce some new darker colours for an array of html colors.

Using this:
http://blog.lotusnotes.be/domino/archive/2007-08-04-javascript-color-functions.html

I built this:
    <div id='outputLifeLine'>
    </div>
    <script type="text/javascript">
        var arr = [[-18, '#00ff00'],
        [-4, '#aaff00'],
... snip...
        [18, '#ff2200']];

        var G = {}, $ = function(a) { return document.getElementById(a) };

        G.color = {
            rgb: function(a) {
                var o = a.toLowerCase();
                return [parseInt(o.slice(0, 2), 16), parseInt(o.slice(2, 4), 16), parseInt(o.slice(4), 16)];
            },
            shade: function(a, b) {
                var v = [], i;
                for (i = 0; i < 3; i++) {
                    v[i] = Math.round(a[i] * b)
                    if (v[i] > 255) v[i] = 255
                    if (v[i] < 0) v[i] = 0
                }
                return v
            },
            hex: function(a) { var f = G.color._hex; return f(a[0]) + f(a[1]) + f(a[2]) },
            _hex: function(a) { return ('0' + a.toString(16)).slice(-2) }
        };

        var txt = '';
        var m = G.color;
        for (var i in arr) {
            var n = m.rgb(arr[i][1].substr(1));
            txt += "[" + arr[i][0] + ",'" + arr[i][1] + "', '#" + m.hex(m.shade(n, 0.6)) + "'],";
            txt += "<br/>"
        }
        var d = document.getElementById("outputLifeLine");
        d.innerHTML = txt;

</script>

And then ran it... Nothing special... but thought I'd share it!

Monday, November 02, 2009

The perils of Javascript - Number.MIN_VALUE

Just spent some time debugging a problem....

I had a filter set up in my new player code on runsat - and when the filter was disabled I was setting the filter limits to Number.MIN_VALUE and Number.MAX_VALUE.

When a calculation results in a number greater than Number.MAX_VALUE, it is assigned a value of Number.POSITIVE_INFINITY.

When a calculation results in a number less than Number.MIN_VALUE, it is assigned a value of Number.NEGATIVE_ INFINITY.


However.... this is complete "codswollop" - actually MIN_VALUE is an epsilon value - it's the smallest positive fraction allowed in javascript - so it's not negative - in fact it's almost (but not quite) zero.

Looking around loads of sites contain big info on this!

Yikes!

Friday, October 16, 2009

DNN - installing AjaxToolkit ahead of UKNuke RPX authentication

These were the draft steps I wrote about how to install the popup login functionality...

This is still in development... not really ready for primetime yet!

Stuart

1. AjaxToolkit

You need the AjaxToolkit installed within your DNN bin folder. This can be downloaded fromhttp://www.codeplex.com/AjaxControlToolkit. To install it you may also need to update your System.Web.Extensions.dll to a more recent version (and indeed you may need to update the whole portal to .Net 3.5). 

I can't assist you with this part in detail here - but there are quite a few links/instructions out there on Bing/Google!

One thing that helped me was updating web.config to include this "bindingRedirect" section:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>

- this taken from a DNN 5.1.4 example portal.

2. Install the new RPX module I just sent you

3. Change your skin

You'll need to add this to the top of your skin:
<%@ Register TagPrefix="uknuke" TagName="Login" Src="~/DesktopModules/AuthenticationServices/UkNuke.RPX/LoginButton.ascx" %>

And you'll need to add this wherever you want the login link to appear:
<uknuke:Login ID="specialLogin" runat="server"></uknuke:Login>

4. That should be it :)

Some difference in DNN 5.1.4 - logging into SQL2005

For some reason my old connection strings - which started "Server=(local);" no longer work in DNN 5.1.4


Basically, the connection string now starts "(local);" 

Thursday, October 15, 2009

Getting AjaxToolkit to work in an old project

I was trying to update an old DotNetNuke project so it would use the AjaxToolkit.

To do this I had various problems with System.Web.Extensions versioning.

After some pain, I discovered one solution was to add this section to the web.config file :)

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="bin;bin\HttpModules;bin\Providers;bin\Modules;bin\Support;" />
 <dependentAssembly>
 <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
 <bindingRedirect oldVersion="1.0.61025.0" newVersion="3.5.0.0"/>
 </dependentAssembly>
 <dependentAssembly>
 <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
 <bindingRedirect oldVersion="2.0.0.0" newVersion="3.5.0.0"/>
 </dependentAssembly>
 </assemblyBinding>  
  </runtime>

Tuesday, October 13, 2009

Finding a table name

I knew my table had "comment" in it... so I used this to find out the table name

SELECT name
FROM dbo.sysobjects
WHERE xtype = 'U' AND NAME LIKE '%COMMENT%'

I could also have used xtype:
'V' - views
'S' - system tables

From: http://database.ittoolbox.com/documents/finding-table-names-in-sql-18556 - thanks!

Tuesday, October 06, 2009

SagePay processing for nopcommerce - my first codeplex launch

Spent lots of today coding a SagePay payment processor for NopCommerce.

The details of it are on cirrious at: http://www.cirrious.com/Research/NopCommerceSagePay/tabid/62/Default.aspx

And I've launched it as a codeplex project at: http://nopsage.codeplex.com/

Overall I'm quite impressed with the support info available at http://www.sagepay.com/ - and their simulator is very useful for testing.

Friday, September 25, 2009

Creating an ActiveX object and running it in a browser

I'm such an old fuddy duddy... that I'd never really tried COM wrapping on C# objects.

But today all that changed...

This blog post helped lots:
http://blog.ianchivers.com/wordpress/?p=22

I'll try to actually post the code on this later... it's a nice way of extending a web app in an Intranet environment (it's not for Internet...)

Saturday, September 12, 2009

An excellent explanation of the confusion that reigns between ASP.Net 2.0 and 3.x

This is something I've come across more than once now - people complaining their ASP.Net 3.5 applications are running as 2.0 and not being able to set them in IIS...

Here's a superb explanation of what 3.0 and 3.5 added to 2.0 - and how they did it without changing the core runtime
http://www.hanselman.com/blog/HowToSetAnIISApplicationOrAppPoolToUseASPNET35RatherThan20.aspx

Monday, September 07, 2009

Adding direct SQL editing/browsing access to any website...

I was editing a nopcommerce website that I only had http and ftp access to - no sql access.

So I needed a way to execute some SQL scripts.

To do this I added (to the administration pages) the following

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SQLRunner.aspx.cs" MasterPageFile="~/Administration/main.master" Inherits="NopSolutions.NopCommerce.Web.Administration.SQLRunner" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cph1" runat="server">
    SQL:
    <br />
    <asp:TextBox ID="tbSQL" runat="server" Columns="80" Rows="10" TextMode="MultiLine">
    </asp:TextBox>
    <br />
    <asp:CheckBox ID="cbScript" runat="server" Text="Run as script" />
    <asp:Button ID="btnGo" runat="server" Text="Go" OnClick="btnGo_OnClick" />
    <br />
    <asp:Panel ID="pnlOutput" runat="server" Visible="false">
        <asp:GridView ID="grdResults" runat="server"></asp:GridView>
    </asp:Panel>
    <asp:Label ID="lblResult" runat="server" >
    </asp:Label>
</asp:Content>


coupled with this source

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NopSolutions.NopCommerce.Web;
using NopSolutions.NopCommerce.DataAccess;
using System.Configuration;
using System.Data.SqlClient;

namespace NopSolutions.NopCommerce.Web.Administration
{
    public partial class SQLRunner : BaseNopAdministrationPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnGo_OnClick(object sender, EventArgs e)
        {
            try
            {
                var sqlConnection = NopSqlDataHelper.CreateConnection(ConfigurationManager.ConnectionStrings["NopSqlConnection"].ConnectionString);
                var sqlCommand = sqlConnection.GetSqlStringCommand(tbSQL.Text);
                if (cbScript.Checked)
                {
                    sqlConnection.ExecuteNonQuery(sqlCommand);

                    pnlOutput.Visible = false;
                }
                else
                {
                    var dataSet = sqlConnection.ExecuteDataSet(sqlCommand);

                    pnlOutput.Visible = true;
                    grdResults.DataSource = dataSet;
                    grdResults.DataBind();
                }
                lblResult.Text = "OK";
            }
            catch (Exception exc)
            {
                lblResult.Text = string.Format("Exception seen - {0} - {1}", exc.GetType().Name, exc.Message);
            }
        }
    }
}

Seems to work OK :)