May 8, 2012

Certificate access permissions

In Windows Resource Kit there is a utility winhttpcertcfg.exe.

List certificate key permissions:
winhttpcertcfg.exe -l -c LOCAL_MACHINE\My -s "certificate.name"

 

Grant permissions to a certificate key:
winhttpcertcfg.exe -g -c LOCAL_MACHINE\My -s "certificate.name" -a WindowsAccount

 

Grant account permissions to run as a Windows service:
Logon as service policy

 

Grant account permissions to run as an ASP.NET application service:
aspnet_regiis -ga WindowsAccount

 

Give WindowsAccount write permissions to C:\Windows\Temp

If the certificate is not in this store and you want to move it there from another location, you must export the certificate and then import it. Do not drag and drop it in the Certificates MMC UI or it won't work.

Apr 13, 2012

PostSharp

http://www.sharpcrafters.com/

Aspect-oriented framework for .NET.

Name: OnExceptionAspect
Level: method
Note: exception handling in a marked method

Name: OnMethodBoundaryAspect
Level: method, class, assembly
Notes: intercepts certain points in a method’s execution: OnEntry, OnExit, OnSuccess, OnException

Name: MethodInterceptionAspect
Level: method
Notes: replaces method's contents that can be invoked
Example use: wait/retry, automatic thread delegation, lazy loading and validation

Name: LocationInterceptionAspect
Level: field, property
Notes: OnGetValue and OnSetValue
Example use: lazy loading, IoC Resolution

 

Subtle Patterns

http://subtlepatterns.com/

Cassette

http://getcassette.net

Bundle and minify scripts and stylesheets.

Reference files in javascript files to be automatically included (with intellisense in VS):
 /// <reference path="jquery.js"/>

Jan 30, 2012

Keeping it Simple, Template Routine


  1. Push Ups 3-4 sets of maximum repetitions (resting 1-2 minutes between sets) vary width between arms

  2. Pull Ups 3 sets of maximum repetitions (resting 2-3 minutes between sets) focusing on pulling as quickly as possible

  3. Forward Squats 4-5 sets of maximum repetitions (resting 1-2 minutes between sets) focus on moving both ends of the femur simultaneously

  4. Ankle Raises 3-4 sets of maximum repetitions (resting 2-3 minutes between sets) focus on constantly keeping your heels raised off the ground

  5. Twisting Crunches 3-4 sets of maximum repetitions (resting 2-3 minutes between sets) focus on using core muscles

  6. Plank 2 sets of holding for 1-2 minutes (resting 2-3 minutes between sets) if you have any back problems, avoid this exercise

  7. Leg Raises 3 sets of maximum repetitions (resting 2-3 minutes between sets) focus on using lower abdominals

Feb 4, 2011

Serialize and Deserialize object to DB / XElement


//To serialize into XElement:

        XmlSerializer x = new XmlSerializer(typeof(ComplexType));
        XDocument doc = new XDocument();
ComplexType ct = _getComplexType();
using (XmlWriter xw = doc.CreateWriter())
{
ComplexType ct = _getComplexType();
x.Serialize(xw, complexType);
xw.Close();
}
XElement el = doc.Root;

//To deserialize into ComplexType:

        using (XmlReader xr = el.CreateReader())
        {
            ComplexType deserializedComplexType =
x.Deserialize(xr) as ComplexType;
            xr.Close();
        }

Feb 3, 2011

Exposing unreferenced data types via WCF service

For example, need to expose an enumeration that is not used by any of the WCF service operations to the client (via WSDL).

While ServiceKnownType attribute on the service class/interface/method exposed the type in the XSD schema of the WSDL, the default client proxy generation does not generate code for it.

Eventually ended up with a dummy solution of having a dummy method:


public class ExposedDataTypes
{
public CustomType1 type1 { get; set; }
public CustomType2 type2 { get; set; }
}



ExposedDataTypes IService.Ignore()
{
return null;
}


Not the best solution, but couldn't gracefully work around it. Easy and works nicely though.