code & chips

general programming stuff…

Git with no deep sh*t

leave a comment »

I am trying to learn git, a distributed code version system, but it is proving to be difficult as it seems every resource aiming at helping understand it does nothing but confuse matters.

(Personally, I have no idea why it is so complex other than geeky vanity the users must have)

Anyway, Roger Dudler has created a great “Git Guide” that he describes as, :just a simple guide for getting started with git. no deep shit ;) “, and that is precisely what I was looking for.  The basics.

Roger Dudler – Git Guide

Written by Kam

January 9, 2012 at 2:23 pm

Posted in Uncategorized

Tagged with

InSync – DropBox for Google

leave a comment »

I’ve been looking for something like this for a while now.

It’s like DropBox but connects to your Google account and uses your Google space.

The files show up in your Google Documents.

InSync

Written by Kam

December 30, 2011 at 5:15 pm

Posted in Uncategorized

Tagged with

Tip-Top Online CSS, HTML, JS & DOM Reference

leave a comment »

Written by Kam

December 7, 2011 at 8:53 pm

Posted in Uncategorized

Tagged with , , ,

DOS WCF host and client

leave a comment »

It’s no secret that I have no love for the WCF declarative configuration and I find testing through an IIS host a whole faff.  This is why I use a DOS host and client to easily test the transportation of data as my first port of call in testing.

WCF DOS Host

private static void RunHost()

{

var host = new ServiceHost(typeof(TestWcfService));

 

var httpBinding = new BasicHttpBinding

{

MaxBufferPoolSize = 0,

MaxReceivedMessageSize = Int32.MaxValue,

MaxBufferSize = Int32.MaxValue,

TransferMode = TransferMode.Streamed

};

 

var wsHttpBinding = new WSHttpBinding

{

MaxBufferPoolSize = 0,

MaxReceivedMessageSize = Int32.MaxValue,

ReliableSession = {Enabled = true, Ordered = true}

};

 

var netTcpBinding = new NetTcpBinding

{

MaxBufferPoolSize = 0,

MaxReceivedMessageSize = int.MaxValue,

MaxBufferSize = int.MaxValue,

ReliableSession = {Enabled = true, Ordered = true}

};

 

var netNamedPipe = new NetNamedPipeBinding

{

MaxBufferPoolSize = 0,

MaxReceivedMessageSize = int.MaxValue,

MaxBufferSize = int.MaxValue

};

 

host.AddServiceEndpoint(typeof(ITestService), httpBinding, “http://localhost/basic”);

host.AddServiceEndpoint(typeof(ITestService), wsHttpBinding, “http://localhost/ws”);

host.AddServiceEndpoint(typeof(ITestService), netTcpBinding, “net.tcp://localhost/tcp”);

host.AddServiceEndpoint(typeof (ITestService), netNamedPipe, “net.pipe://localhost/pipe”);

 

var operation = host.Description.Endpoints[0].Contract.Operations.Find(“TestCollectionParameter”);

operation.Behaviors.Find<DataContractSerializerOperationBehavior>().MaxItemsInObjectGraph = Int32.MaxValue;

 

try

{

host.Open();

PrintConnectionInformation(host);

Console.WriteLine(“Listening….”);

Console.ReadLine();

Console.WriteLine(“Closing channels…”);

 

host.Close();

}

catch (Exception ex)

{

Console.WriteLine(ex.Message);

host.Abort();

throw;

}

}

 

private static void PrintConnectionInformation(ServiceHostBase host)

{

host.Description.Endpoints.ToList().ForEach(ep => Console.WriteLine(String.Format(“{0} running at {1}”, ep.Name, ep.ListenUri)));

}

 

WCF DOS Client

 

public class CustomChannelFactory<T> : ChannelFactory<T>

{

public CustomChannelFactory(Binding binding) : base(binding) { }

 

public CustomChannelFactory(ServiceEndpoint endpoint) : base(endpoint) { }

 

public CustomChannelFactory(string endpointConfigurationName) : base(endpointConfigurationName) { }

 

public CustomChannelFactory(Binding binding, EndpointAddress remoteAddress) : base(binding, remoteAddress) { }

 

public CustomChannelFactory(Binding binding, string remoteAddress) : base(binding, remoteAddress) { }

 

public CustomChannelFactory(string endpointConfigurationName, EndpointAddress remoteAddress) : base(endpointConfigurationName, remoteAddress) { }

 

protected override void OnOpening()

{

foreach (var behavior in

Endpoint.Contract.Operations.Select(operation => operation.Behaviors.Find<DataContractSerializerOperationBehavior>()).Where(behavior => behavior != null))

{

behavior.MaxItemsInObjectGraph = int.MaxValue;

}

base.OnOpening();

}

}

 

[ServiceContract]

public interface ITestService

{

[OperationContract]

string TestStringReturn();

 

[OperationContract]

string TestCollectionParameter(List<string> data);

}

 

private static void TestConnectBasicHttpBinding()

{

var binding = new BasicHttpBinding

{

MaxBufferSize = Int32.MaxValue,

MaxReceivedMessageSize = Int32.MaxValue,

MaxBufferPoolSize = Int32.MaxValue,

TransferMode = TransferMode.Streamed,

SendTimeout = new TimeSpan(0, 0, 10, 0),

ReceiveTimeout = new TimeSpan(0, 0, 10, 0)

};

 

Console.WriteLine(“Connecting through basic HTTP channel.”);

 

var factory = new CustomChannelFactory<ITestService>(binding, “http://localhost/basic”);

 

var channel = factory.CreateChannel();

 

try

{

var x = channel.TestStringReturn();

 

Console.WriteLine(“Returned Value: {0}”, x);

}

catch (Exception ex)

{

if (channel != null)

((IClientChannel)channel).Abort();

 

Console.WriteLine(ex.Message);

}

}

Written by Kam

September 29, 2011 at 9:29 pm

Posted in Uncategorized

Tagged with

WCF Setup Problems

leave a comment »

WCF has to be one of the most frustrating technologies I have ever used.  The problems I encountered tonight were in the setup.  Like most things development, the trick is in the setup.  Unfortunately, I spend a lot of time tweaking the settings on my new development machine install, but I never remember or even note down the tweaks I made to get things to work.  So when I rebuild my machine, I am back to square one.

The WCF configuration has too many things that not only look the same, but the declarative nature – while flexible – in most cases is just a pain in the ass and I found it easier to simply hard code the values as in my experience, they rarely change.

Anyway, setting up my WCF IIS host on a new development machine proved to be more involved than I initially credited it would be.

When setting up the IIS host for a WCF library you will need to create an SVC file.  But, this file extension may not be recognised by IIS – making things ‘tricky’. So here are some things to look out for in order:

  • Try installing the ASP components from the Windows Components in Programs & Services.
  • Try ServiceModelReg -ia to install all the WCF components onto your machine.
  • Try asp net-regiis -i to install the handler configurations to IIS.
  • Sometimes you get a problem where you do not have permissions to run the web application from the current – normally – default application pool.  So try setting the user account to LocalSystem in IIS for the corresponding application pool.

Written by Kam

August 19, 2011 at 12:43 am

Posted in Uncategorized

Tagged with ,

Delay/Test Signing Assemblies and Testing

leave a comment »

Note to self:

When delay/test signing your assemblies remember to run the follwing command before running unit tests:

sn -Vr myAssembly.dll

All my unit tests were failing because the .NET framework – and so the test runner – would not allow me to load an assembly that it considered to be tampered.  Delay/Test is essentially tampering, by signing the public key and allocating space for the private key.

So make sure to run the above command to configure the .NET framework to skip strong name verification for the delay/test signed assembly or application.

That was 2 hours wasted…..

Written by Kam

July 31, 2011 at 12:34 am

Posted in Uncategorized

Tagged with ,

Microsoft SqlServer SMO Assembly Location

leave a comment »

I have just spent the last hour trying to locate – by hook, crook and Google – the location of the SMO assemblies I need to develop a sql management application in C#.

I found it and need to log it:

{Program Files}\Microsoft SQL Server\100\SDK\Assemblies

 

Written by Kam

July 6, 2011 at 4:37 pm

Posted in Uncategorized

Tagged with

Invalid TraceListenerData type in configuration – Enterprise Library Logging Application Block

leave a comment »

Invalid TraceListenerData type in configuration ‘listenerDataType=\”Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35\”‘


The reason I got this error was for two reasons:

1) Add the Enterprise Library Logging Application Block Data Provider assembly from the GAC

2) For some reason all new projects default to the .NET 4 Client Profile.  Change the project to be a full .NET 4 build via the project properties.  The client profile is preventing the application from picking up assemblies it requires.

How’s that for painful ball achingly annoying problems?  All because the Microsoft documentation – as always – is wholly inadequate…..

 

Written by Kam

March 8, 2011 at 12:33 am

Posted in Uncategorized

Tagged with , ,

Tortoise SVN “File or Directory is Corrupted and Unreadable” on Windows 64 bit

leave a comment »

The error I am talking about is this one:

Error: Can't move
Error: '[...]\\.svn\tmp\entries'
Error: to
Error: '[...]\\.svn\entries':
Error: The file or directory is corrupted and unreadable.

 

While there are other articles that tell you that this is a bug in Windows 7 and that a hotfix will solve it, I found that my anti virus/spyware was to blame.

TortoiseSVN  + Windows 7 + 64 Bit + Microsoft Security Essentials = <error>

 

If you switch off your antivirus/spyware, you may find this error disappears..

Written by Kam

February 21, 2011 at 6:20 pm

Posted in Uncategorized

Tagged with ,

Reactivating Windows 7 after a Hardware Change

with one comment

Start => Run => slui.exe 4

Follow instructions!!!

Written by Kam

February 6, 2011 at 10:35 pm

Posted in Uncategorized

Tagged with

Follow

Get every new post delivered to your Inbox.