WithFollow link from wordpress

Found how to get a With-Follow link from wordpress.org, two pages away from a PR7. Hopefully WordPress doesn’t read this post! 🙂

But, the author URL is with-follow (no rel=nofollow), so if you author a widget, and supply a url, then this will pass rank from WordPress to your site.

Another trick to this, is tag the plugin with a one of the following popular tags:
    *  widget (1410)
    * Post (1059)
    * plugin (850)
    * admin (798)
    * posts (774)
    * sidebar (718)
    * comments (609)
    * images (462)
    * google (444)
    * page (432)
    * links (431)
    * twitter (423)
    * rss (360)

This means that your plugin will get a link from the front of the plugins page, for a week ("Rss" is the best tag for this).

Categories: Uncategorized

Sending SMS from Silverlight

I downloaded VS 2008 SP1, and the Silverlight SDK. Dissappointed to see that there was no obvious "design view" for silverlight, I guess Microshaft wants us all to buy Expression Blend, so I just created a canvas with a giant button in XAML

<UserControl xmlns:dataInput="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input"  x:Class="HelloSilverlight.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml&quot;
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008&quot; xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
  <Grid x:Name="LayoutRoot">
     <Button Content="Send SMS" Click="Button_Click"></Button>
  </Grid>
</UserControl>

Added a reference to http://www.freebiesms.co.uk/sendsms.asmx

Added using HelloSilverlight.FreebieSMS; to the namespace includes.

Then, this as the event handler

 private void Button_Click(object sender, RoutedEventArgs e)
        {
            // Button clicked
            sendSmsSoapClient SMS = new sendSmsSoapClient();
            SMS.SendSmsAsync("Bob", "00447866069537", "00447866069535", "Test from Silverlight", "en-GB");
        }

All downloadable from http://sites.google.com/site/freesmsuk/silverlight

Categories: Uncategorized

When not to use affiliate data feed XML

Many affiliate programs give away their product databases, in the hopes that you can sell their stuff better than they can, but it certainly is not the way to create generic content.

I downloaded Beepy’s product database at
http://www.beepy.co.uk/datafeeds/mobile_datafeed_dgm_product_feed.xml.gz, Here’s an excerpt of the XML

w995-black.jpg</largeimageurl><brand>Sony Ericsson</brand><condition>New</condit
ion><location>UK</location><shortdescription>With a model number like 995, you g
et the impression Sony Ericsson want you to know this is a high-end, top quality
 product. So surely with a tag like this, the W995 makes the tea, takes out the
dustbin and prepares a lovely four course meal for you. OK, so it doesn’t do any
 of those things, but this is one phone which brings the best of both the Walkma
n and CyberShot range of phones together in one fantastic package, whilst even f
inding space to squeeze in one of the most requested Sony Ericsso</shortdescript

I picked a phrase that was relatively unique in the description, then put it into google.

http://www.google.co.uk/#hl=en&q=%22So+surely+with+a+tag+like+this,+the+W995+makes+the+tea%22&start=20&sa=N&fp=819eb60ddcc41d13

66,700 exact matches.

of which on 37 got listed, and the other 66,663 got stuffed into the supplemental index.

ergo, if you created a site with this content, you have a 99.9% chance of ending up in the supplemental index.

Categories: Uncategorized

WordPress fails to install on Microsoft web app installer

Installing the Worpress plugin

http://www.microsoft.com/web/gallery/WordPress.aspx
Press install
Install the Web Platform Installer
Select Web Applications > All > WordPress
Install
I Accept
Administrator username ‘root’
password: xxx

Failed; when installing MYSQL .NET connector
Log:
(Action=ManagedWebInstall,ActionType=3073,Source=BinaryData,Target=CAQuietExec,CustomActionData="C:Windows\Microsoft.NETFrameworkv2.0.50727installUtil.exe" /LogToConsole=false /LogFile=  "C:Program FilesMySQLMySQL Connector Net 5.2.5Web ProvidersMySql.Web.dll")
MSI (s) (C0:74) [15:27:06:666]: Invoking remote custom action. DLL: C:WindowsInstallerMSI5048.tmp, Entrypoint: CAQuietExec
CAQuietExec:  Microsoft (R) .NET Framework Installation utility Version 2.0.50727.4016
CAQuietExec:  Copyright (c) Microsoft Corporation.  All rights reserved.
CAQuietExec: 
CAQuietExec:  The installation failed, and the rollback has been performed.
CAQuietExec:  Error 0xffffffff: Command line returned an error.
CAQuietExec:  Error 0xffffffff: CAQuietExec Failed

Annoying!

Categories: Uncategorized

Live example of a SimpleDB site

My experiment with Amazon’s SimpleDB lead me to put up a site called Airport Delays.org, which is a site that uses FAA data, stored in a AWS SimpleDB database, read back using the code snippets in previous posts.

The case sensitivity is a pain, since the selects have to match the case of the data, and paging is a problem, since the tokens are huge. and they tend to break IIS
see http://www.airportdelays.org/ByState.aspx/wyoming then press "Next" and it says Bad request. – Worked on my development server ! grr.

I did add a filter by tail number also http://www.airportdelays.org/ByTailNumber.aspx/N434YV which is quite new… might add to it, if people use it.

Categories: Uncategorized

Running Select statements against the Amazon SimpleDB in C#

  public static DataTable SimpleDBSelect(string query, ref string nextToken, out bool eof)
        {
            NameValueCollection appConfig = ConfigurationManager.AppSettings;

             AmazonSimpleDB service = AWSClientFactory.CreateAmazonSimpleDBClient(
                    appConfig["AWSAccessKey"],
                    appConfig["AWSSecretKey"]
                    );

           

            SelectRequest queryRequest = new SelectRequest();
            queryRequest.SelectExpression = query;
            if (query == null)
            {
                eof = true;
                return null;
            }
            queryRequest.NextToken = nextToken;         // Seed for where to start reading
          
            SelectResponse queryResponse = service.Select(queryRequest);
            DataTable dt = new DataTable();
            if (queryResponse.IsSetSelectResult())
            {
                SelectResult selectResult = queryResponse.SelectResult;
                List<Item> itemList = selectResult.Item;
                dt.Clear();
                // Create the columns and name them
                dt.Columns.Add("ItemName", Type.GetType("System.String"));
                if (itemList.Count > 0)
                {
                    for (int i = 0; i < itemList[0].Attribute.Count; i++)
                    {
                        dt.Columns.Add(itemList[0].Attribute[i].Name, Type.GetType("System.String"));
                    }
                    // Now add the data
                    foreach (Item item in itemList)
                    {
                        DataRow dr = dt.NewRow();
                        List<Amazon.SimpleDB.Model.Attribute> attributeList = item.Attribute;
                        dr["ItemName"] = item.Name; ;
                        foreach (Amazon.SimpleDB.Model.Attribute attribute in attributeList)
                        {
                            dr[attribute.Name] = attribute.Value;
                        }
                        dt.Rows.Add(dr);
                    }
                }
            }
            if (queryResponse.SelectResult.NextToken != null)
            {
                nextToken = CleanseToken(queryResponse.SelectResult.NextToken);
                eof = false;
            }
            else
            {
                nextToken = null;
                eof = true;
            }
            return dt;
        }

Adapted from Mike Culver’s code on Amazon. Note that SQL statements are CaSe SeNsItiVe!

Categories: Uncategorized

The Apache2.2 service terminated with service-specific error 1 (0x1).

Categories: Uncategorized

Importing a CSV file into Amazon SimpleDB

Here’s some code to import a CSV file into a Amazon SimpleDB database

            Console.WriteLine("Connecting to Amazon Simple DB");
    
            NameValueCollection appConfig = ConfigurationManager.AppSettings;

            AmazonSimpleDB sdb = AWSClientFactory.CreateAmazonSimpleDBClient(
                appConfig["AWSAccessKey"],
                appConfig["AWSSecretKey"]
                );

            // Setup Flights DataStore
            String domainName = "CSV";
            CreateDomainRequest createDomain = (new CreateDomainRequest()).WithDomainName(domainName);
            sdb.CreateDomain(createDomain);

            Console.WriteLine("Created flights DB on Amazon");

            string strCSVFile = @"C:MyFile.csv";
            FileStream fsCSV = new FileStream(strCSVFile, FileMode.Open, FileAccess.Read);
            StreamReader srCSV = new StreamReader(fsCSV);
            string strHeaderLine = srCSV.ReadLine();
            string[] strHeaders = Regex.Split(strHeaderLine, ",");
            // Remove Inverted Commas
            for (int i = 0; i < strHeaders.Length; i++)
            {
                strHeaders[i] = strHeaders[i].Replace(""", "");
            }

            Console.WriteLine("Read column headers");

            string strDataLine = srCSV.ReadLine();
            while(!string.IsNullOrEmpty(strDataLine))
            {
                string[] strData = Regex.Split(strDataLine, ",");
                if (strData.Length < strHeaders.Length) continue;
                strDataLine = srCSV.ReadLine();
                PutAttributesRequest putAttributesAction = new PutAttributesRequest().WithDomainName(domainName).WithItemName(Guid.NewGuid().ToString());
                List<ReplaceableAttribute> attributes = putAttributesAction.Attribute;               
                for (int i = 0; i < strHeaders.Length-1; i++)
                {
                    strData[i] = strData[i].Replace(""", "");
                    attributes.Add(new ReplaceableAttribute().WithName(strHeaders[i]).WithValue(strData[i]));              
                }
                sdb.PutAttributes(putAttributesAction);
                Console.WriteLine(strDataLine);
            }

Categories: Uncategorized

More than one endpoint configuration for that contract was found

In VS 2008, when you add a web refrence to a windows forms app, it works a little differently, createing a "service" reference. This causes
some problems with web services that have more than one binding, i.e. designed to support Soap 1.0 and Soap 1.2.

This was the first sign of this nasty quirk;
An endpoint configuration section for contract ‘FreebieSMSWebservice.BulkSMSSoap’ could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name.

If you open the Configuration.svcinfo file, then scroll to the end right, you’ll see the xml (below). Where I’ve highlighted the endpoint names;
So then the client code becomes:

            BulkSMSSoapClient SMS = new BulkSMSSoapClient("BulkSMSSoap");
            double dCredit = SMS.GetRemainingCredit("xxxx", "xxxx");
            MessageBox.Show(dCredit.ToString());

Where the parameter sent to the constructor is the endpoint name.

<?xml version="1.0" encoding="utf-8"?>
<configurationSnapshot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd="http://www.w3.org/2001/XMLSchema&quot; xmlns="urn:schemas-microsoft-com:xml-wcfconfigurationsnapshot">
  <behaviors />
  <bindings>
    <binding digest="System.ServiceModel.Configuration.BasicHttpBindingElement, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089:&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&lt;Data hostNameComparisonMode=&quot;StrongWildcard&quot; maxBufferSize=&quot;65536&quot; messageEncoding=&quot;Text&quot; name=&quot;BulkSMSSoap&quot; textEncoding=&quot;utf-8&quot; transferMode=&quot;Buffered&quot;&gt;&lt;readerQuotas maxArrayLength=&quot;16384&quot; maxBytesPerRead=&quot;4096&quot; maxDepth=&quot;32&quot; maxNameTableCharCount=&quot;16384&quot; maxStringContentLength=&quot;8192&quot; /&gt;&lt;security mode=&quot;None&quot;&gt;&lt;message algorithmSuite=&quot;Default&quot; clientCredentialType=&quot;UserName&quot; /&gt;&lt;transport clientCredentialType=&quot;None&quot; proxyCredentialType=&quot;None&quot; realm=&quot;&quot; /&gt;&lt;/security&gt;&lt;/Data&gt;" bindingType="basicHttpBinding" name="BulkSMSSoap" />
    <binding digest="System.ServiceModel.Configuration.CustomBindingElement, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089:&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&lt;Data name=&quot;BulkSMSSoap12&quot;&gt;&lt;httpTransport allowCookies=&quot;false&quot; authenticationScheme=&quot;Anonymous&quot; bypassProxyOnLocal=&quot;false&quot; hostNameComparisonMode=&quot;StrongWildcard&quot; keepAliveEnabled=&quot;true&quot; manualAddressing=&quot;false&quot; maxBufferPoolSize=&quot;524288&quot; maxBufferSize=&quot;65536&quot; maxReceivedMessageSize=&quot;65536&quot; proxyAuthenticationScheme=&quot;Anonymous&quot; realm=&quot;&quot; transferMode=&quot;Buffered&quot; unsafeConnectionNtlmAuthentication=&quot;false&quot; useDefaultWebProxy=&quot;true&quot; /&gt;&lt;textMessageEncoding maxReadPoolSize=&quot;64&quot; maxWritePoolSize=&quot;16&quot; messageVersion=&quot;Soap12&quot; writeEncoding=&quot;utf-8&quot;&gt;&lt;readerQuotas maxArrayLength=&quot;16384&quot; maxBytesPerRead=&quot;4096&quot; maxDepth=&quot;32&quot; maxNameTableCharCount=&quot;16384&quot; maxStringContentLength=&quot;8192&quot; /&gt;&lt;/textMessageEncoding&gt;&lt;/Data&gt;" bindingType="customBinding" name="BulkSMSSoap12" />
  </bindings>
  <endpoints>
    <endpoint normalizedDigest="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&lt;Data address=&quot;http://www.freebiesms.co.uk/bulksms.asmx&quot; binding=&quot;basicHttpBinding&quot; bindingConfiguration=&quot;BulkSMSSoap&quot; contract=&quot;FreebieSMSWebservice.BulkSMSSoap&quot; name=&quot;BulkSMSSoap&quot; /&gt;" digest="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&lt;Data address=&quot;http://www.freebiesms.co.uk/bulksms.asmx&quot; binding=&quot;basicHttpBinding&quot; bindingConfiguration=&quot;BulkSMSSoap&quot; contract=&quot;FreebieSMSWebservice.BulkSMSSoap&quot; name=&quot;BulkSMSSoap&quot; /&gt;" contractName="FreebieSMSWebservice.BulkSMSSoap" name="BulkSMSSoap" />
    <endpoint normalizedDigest="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&lt;Data address=&quot;http://www.freebiesms.co.uk/bulksms.asmx&quot; binding=&quot;customBinding&quot; bindingConfiguration=&quot;BulkSMSSoap12&quot; contract=&quot;FreebieSMSWebservice.BulkSMSSoap&quot; name=&quot;BulkSMSSoap12&quot; /&gt;" digest="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&lt;Data address=&quot;http://www.freebiesms.co.uk/bulksms.asmx&quot; binding=&quot;customBinding&quot; bindingConfiguration=&quot;BulkSMSSoap12&quot; contract=&quot;FreebieSMSWebservice.BulkSMSSoap&quot; name=&quot;BulkSMSSoap12&quot; /&gt;" contractName="FreebieSMSWebservice.BulkSMSSoap" name="BulkSMSSoap12" />
  </endpoints>
</configurationSnapshot>

Categories: Uncategorized

Writing a text file from SQL server

How to write a text file from SQL server:

1. Create the following Stored Procedure:

CREATE PROCEDURE usp_UseOA (
@File varchar(1000)
, @Str varchar(1000)
)
AS
DECLARE @FS int
, @OLEResult int
, @FileID int

EXECUTE @OLEResult = sp_OACreate
'Scripting.FileSystemObject'
, @FS OUT

IF @OLEResult <> 0

BEGIN
PRINT
'Error: Scripting.FileSystemObject'
END

-- Opens the file specified by the @File input parameter
execute @OLEResult = sp_OAMethod
@FS
, 'OpenTextFile'
, @FileID OUT
, @File
, 8
, 1
-- Prints error if non 0 return code during sp_OAMethod OpenTextFile execution
IF @OLEResult <> 0
BEGIN
PRINT 'Error: OpenTextFile'
END

-- Appends the string value line to the file specified by the @File input parameter
execute @OLEResult = sp_OAMethod
@FileID
, 'WriteLine'
, Null
, @Str
-- Prints error if non 0 return code during sp_OAMethod WriteLine execution
IF @OLEResult <> 0
BEGIN
PRINT 'Error : WriteLine'
END

EXECUTE @OLEResult = sp_OADestroy @FileID
EXECUTE @OLEResult = sp_OADestroy @FS


2. Allow OLE Automation on the database

sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Ole Automation Procedures', 1;
GO
RECONFIGURE;
GO

3. Call the stored proc

usp_UseOA 'c:dfslog.txt','hello world'

NB: The SQL server account will have to have read/write access to the destination folder.

Categories: Uncategorized