Thursday 1 January 2015

Raspberry Pi B+ Controlling the GPIO with wiringPi

To use the pins with C code, you need wiring Pi,
then to work out which pin is what on a b+ and which pin it matches in wiringPi was not obvious for me.

first run gpio readall,
match you physical  eg pin 8 , which is GPIO 14  but for wiringPi is 14

+-----+-----+---------+------+---+--B Plus--+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
|   4 |       7 |     GPIO. 7 |   IN | 0 |  7 || 8  | 1 | ALT0 | TxD     | 15  | 14  |

Friday 30 August 2013

Adding Javascript and other JQuery libraries to MVC

open the file bundleconfig.cs in app_start

add your library

bundles.Add(new ScriptBundle("~/bundles/jquery.autosize").Include(
                   "~/Scripts/jquery.autosize*"));

 

then in Views \ Shared \ _Layout.cshtml add the line:

        @Scripts.Render("~/bundles/jquery.autosize")

Monday 11 March 2013

Elastic Search and SharePoint DataSources




We name our datasources after the sites they're indexing, which in ElasticSearch does'nt realy work well.
ElasticSearch sees the // and : from http:// and cuts them up
so http://thesun.co.uk becomes  4 :
http
thesun
co
uk

or if you use file share \\myserver\logs becomes
myserver
logs


But if you set the datasource field  as " not analyzed "  , then the facet search will work and not cut them up at the special chars

curl -XPUT "http://localhost:9200/crawllog/log/_mapping" -d ' {
    "log" : {
        "properties": {
             "Url":{"type":"string"},
             "ErrorMessage" : { "type" : "string" },
             "Date":{"type":"string"},
             "ErrorDescription":{"type":"string"},
             "ErrorId":{"type":"long"},
             "ContentSource":{"type":"string","index":"not_analyzed"}}}}}'

Monday 10 December 2012

How To Create a WCF web service in a SharePoint site and project.

 

 

1 create a new sharepoint project

clip_image001

2. deploy as a farm solution

3. Right Click on the project, and click on add

then in the add list at the bottom is “add a mapped sharepoint folder”

Map ISAP for authenticated anon svc for anonymous services (anonsvc is underneath ISAPI) (I map ISAPI and I’ll use windows authentication)

clip_image003

4. After adding it then Add a folder to ISAPI (name it you wish)

5. Add a new xml file to that folder, then rename it to svc then add another new item, it is an application configuration file called web.config

clip_image004

6. Create 2 new files, one for the interface and the other one for the implementation and add the System.ServiceModel.dll to the References from the GAC

I created the following interface:


using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
namespace WcfTest
{
[ServiceContract]
public interface IService
{
[OperationContract]
int Add(int x, int y);
}
}


The implementation, you have to add the following to the class: [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] like


using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.Activation;
using System.Text;
namespace WcfTest
{
[AspNetCompatibilityRequirements(RequirementsMode =
AspNetCompatibilityRequirementsMode.Allowed)]
public class Service:IService
{
public int Add(int x, int y)
{
return x + y;
}
}
}


7. Build the project and open the Visual Studio Command Line and type:

Sn –T <pathtoyourdll>\Solutionname.dll 


In my case it is:  

E:\>SN -T e:\Temp\WcfTest\WcfTest\bin\Debug\WcfTest.dll

Microsoft (R) .NET Framework Strong Name Utility  Version 4.0.30319.1

Copyright (c) Microsoft Corporation.  All rights reserved.

Public key token is 9e39caaf61698cf3

E:\>

8. modify the SVC file created some steps above like this:

(The service is namespace.class,namespace )


<%@ ServiceHost Debug="True" Language="C#" CodeBehind="Service.cs"


Service="SharePointWCF.Service,SharePointWCF,Version=1.0.0.0,Culture=neutral,


    PublicKeyToken=9e39caaf61698cf3" %>


The green ones have to be modified based on your names and namespaces. After the services attribute the value is the fully qualified name of the service implementation and the name of the dll.

9. Open the tool from the tools menu called WCF Service Configuration Editor when it open close it down J and right click on the web.config under the ISAPI folder you have created and select the Edit WCF Configuration, if you have not opened the WCF Configuration Editor you would not have that menu here/

10. Click on create new service then browse for the dll of the project in the /bin/debug folder. Click on Next button until you reach the What is the address of your endpoint question, type an correct address, can be anything http://google.com or something like this, you will remove it anyway, but the wizard requires. When the wizard finished click on CTRL+S and close down the Wcf Configuration Editor

clip_image006

11. In your web.config correct / add the following things: (MEX cannot be exposed when NTLM authentication is used)


<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled
="true"/>
<diagnostics>
<messageLogging logMalformedMessages="true"
logMessagesAtTransportLevel="true" />
</diagnostics>
<bindings>
<basicHttpBinding>
<binding
name="BasicHttpBinding_IService">
<security
mode="TransportCredentialOnly" >

<transport clientCredentialType="Ntlm" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior
name="Service.CustomBehavior">
<serviceMetadata
httpGetEnabled="true" />
<serviceDebug />

</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="WcfTest.Service"
behaviorConfiguration="Service.CustomBehavior">
<endpoint address=""
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
bindingNamespace="http://fakeService.eib.org"
contract="WcfTest.IService">
<identity>
<dns
value="localhost" />
</identity>
</endpoint>
<!--<endpoint address="mex"
binding="mexHttpBinding" contract="IMetadataExchange" />-->
</service>
</services>
</system.serviceModel>
</configuration>


DONE!





Wednesday 7 December 2011

Finding files ( SharePoint migration )

Scripted migration means logs full of errors, and sometimes the meaningful stuff is on a line or 2 above:

awk "{lines[NR] = $0} /ps1:45 char:37/ {print lines [NR-7]} {delete lines[NR-7]}" imp2


This handy little awk line gets the line 7 lines above the string you are looking for ( in this case it’s ps1:45 char:37


another way is to use grep –b 3 searchedstring inputfile.txt


which gets all 3 lines before the string, and –a will get the lines after

Thursday 1 December 2011

TF250008: This SharePoint site is not currently associated with a team project in Team Foundation Server

When you get this nasty message in the SharePoint collection of the project.

You get loads of these square error boxes all over the page.

tfserror1

tfs2

Anyway the fix for it is to connect to the SharePoint collection to the TFS project.

Follow the instructions here:

http://msdn.microsoft.com/en-us/library/dd386320(VS.100).aspx

When the instructions say:

To add a SharePoint site as a portal to an existing team project
  1. In Team Explorer, right-click the name of the project, point to Team Project Settings, and then click Portal Settings.

”Team Explorer” Is the window in Visual Studio when you connect to TFS.

Print previous line

Print previous line

Ok This was a test for a plugin for Chrome called AddThis to publish links,
No bad.