Thursday 31 December 2015

Great electrician

Spoke with these guys yesterday on their day off
http://www.checkatrade.com/RKBuilders/
image
and they still gave me great advice which helped me with some light fitting that I had spent the morning struggling with.
Can thoroughly recommend their services. Father and son team, and I spoke to the son, who really knew his stuff when it came to GU10 halogen downlight bayonet fitting.

Wednesday 16 December 2015

Speech with windows powershell

Set-ExecutionPolicy Unrestricted -Force

<#
.Synopsis
   Allows you to speak on a remote computer
   Requires that you have run winrm qc on the remote machine
   or Enable-PSRemoting. And on the local machine you've changed
   Set-Item -Path WSMan:\localhost\Client\TrustedHosts -Value * -Force 
.DESCRIPTION
   Allows you to speak on a remote computer
.EXAMPLE
   Speak-Remote 1 "How are you today" REMOTE_PC
.EXAMPLE
   Speak-Remote -RemoteComputerName REMOTE_PC
#>
function Speak-Remote
{
    [CmdletBinding()]
    [OutputType([int])]
    Param
    (
        # Param1 help description
        [Parameter(Mandatory=$true,
                   ValueFromPipelineByPropertyName=$true,
                   Position=0)]
        [string]
        $Times = (Read-Host "How many Times"),

        # Param2 help description
        [Parameter(Mandatory=$true,
                   ValueFromPipelineByPropertyName=$true,
                   Position=1)]
        [string]
        $Message = (Read-Host "What should I say"),

        [Parameter(Mandatory=$true,
                   ValueFromPipelineByPropertyName=$true,
                   Position=2)]
        [string]
        $RemoteComputerName
    )

    Begin
    {
    }
    Process
    {
        Invoke-Command -ScriptBlock {Param($msg, $n) Add-Type -AssemblyName System.Speech; $o = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer; $o.SelectVoice("Microsoft Zira Desktop") ; $y = 0; do { $o.Speak($msg);$y = $y + 1;} until ($y -eq $n) } -ComputerName $RemoteComputerName -ArgumentList $Message, $Times
    }
    End
    {
    }
}

Speak-Remote -RemoteComputerName REMOTE_PC

Thursday 3 September 2015

How to convert C# bool to Javascript boolean in Razor .cshtml views

I was wanting a clean way to convert a C# Boolean property on a view model into a javascript true / false bit of text for passing into our Typescript context settings constructors, and stumbled upon this way …

@Json.Encode(Model.BoolPropertyName)

clip_image002

Works a treat too!

clip_image004

Monday 20 July 2015

The case of the disappearing TFS task board

So after wondering where all our tasks had disappeared to, it turns out that someone had changed the default Area path, and ticked it in the _admin/_areas section of the portal.

This has the knock on affect of removing any items from the task board that are not under ticked area paths, hence the stuff that was in our task board disappeared, even though the items were all still there in TFS and accessible via team explorer.

Wednesday 15 July 2015

Work Item finding with advanced search criteria in Visual Studio 2013

Hi guys

Something that's proving very useful to me now is the fact that you can use advanced search functionality in the quick search box in Visual Studio 2013 to find tickets that you're after.

Example 1,

1. Hit Ctrl+# to enter the team explorer search box

2. Drop down the arrow, and click the assigned to
image

3. Hit enter

This will then find all the work items assigned to you by default, although you can change the name to someone else to see what they're working on e.g.

image

Example 2 ,

1. Hit Ctrl+# to enter the team explorer search box

2. Type "Stack Rank":3.75

3. Hit Enter

You'll then get back all items where the stack rank is equal to 3.75

clip_image006

Other search examples as follows:

For all work items that have been changed on a given date

"Changed Date":2015-07-14

For all work items authorized by someone

"Authorized As":"Name Here"

For all bugs changed today

T:"Bug" "Changed Date":2015-01-14

For all items that you uploaded to TFS today

"Authorized As":"@Me" "Changed Date":2015-07-14

That last one is particularly useful, if you've just forgotten the task number you checked in and closed

image

Wednesday 8 July 2015

SQL Management Studio short cuts

Hi guys

Not sure how many of you already knew this, but stumbled across a couple of SQL management studio shortcuts today that I was previously unaware of, and hit quite by accident.

Subsequently discovered that you can pre-configure your own as well, in  Tools, Options,  Keyboard….

clip_image002

More here

https://msdn.microsoft.com/en-us/library/ms174205.aspx

Thursday 14 May 2015

C# 6 and Roslyn plugins to VS 2015 RC

In order to get the refactoring support listed here...

https://github.com/DustinCampbell/CSharpEssentials

you can simply install the following versions of the Tools, Extensions and Updates in Visual Studio 2015 RC.

image

Monday 11 May 2015

New Language Features in C# 6

A list of new language features summarised here

https://github.com/dotnet/roslyn/wiki/Languages-features-in-C%23-6-and-VB-14

and more detailed for C# only,...

https://github.com/dotnet/roslyn/wiki/New-Language-Features-in-C%23-6

How to retrieve nested property values in JavaScript / Typescript

Use the following function to retrieve the value of a property nested within another property in JavaScript...

 

export function retriveValueFromNestedProperty(objectToIterate: any, propertyName: string): any {

    var array: Array<string> = propertyName.split(".");

    var currentValue: any = objectToIterate[array[0]];

    for (var i = 1; i < array.length; i++) {

        currentValue = currentValue[array[i]];
    }

    return currentValue;
}

Wednesday 22 April 2015

Catastrophic failure when attaching Visual Studio Debugger to IISExpress

Symptom: Unable to attach to the process. Catastrophic failure.
Resolution: Change project settings to enable edit and continue, then press F5 to start the web project in debug mode.
image
I also deleted my solution.suo file from the solutions directory as it was over 3MB! - more about that here -http://merrickchaffer.blogspot.co.uk/2012/02/visual-studio-hanging-running-slowly.html


Monday 23 February 2015

Windows 7 Weather Gadget: Cannot connect to service issue

Please follow this to fix the issue.

  1. Go to %localappdata%\Microsoft\Windows Live\Services\Cache
  2. Open "Config.xml" , Right click on it Select Edit, it will open in Notepad.
  3. Click on File>> Save (without doing any changes)
  4. Restart the Gadget after a Minute and it should start working.

However, it may be a temporary fix.  Many (myself included) report the problem returning. 

(Note: This fix appears to work, even if you're testing in IE10 with ActiveX settings as follows, using this code here http://jsfiddle.net/4aww6o3t/

and you get the Access is denied error from the call to oMSN.GetService("weather")

image

try
{
    // Connect to Weather Service .dll
    var oMSN = new ActiveXObject("wlsrvc.WLServices");
    var oMSN2 = new ActiveXObject("wlsrvc.WLServices");
    this.oMSN = oMSN.GetService("weather"); // Object to send and recieve weather data queries and to poll for service existence
    this.oMSN2 = oMSN2.GetService("weather"); // Object to send a latlong query and recieve a location code corresponding to the latlong
}
catch (objException)
{
    this.isValid = false;
    this.statusMessage = getLocalizedString('ServiceNotAvailable');
    this.oMSN = new Object();
    this.oMSN2 = new Object();
}

Update: 10:48 03/03/2015

Have just managed to write a batch file that fixes this issue ongoing. By adding this batch file to a scheduled task using the Task Scheduler, I've managed to get the gadget to always work now.

Note to use this batch file you'll just have to create a copy of the Settings.ini and call it Settings3Monitors.ini in the folder %userprofile%\AppData\Local\Microsoft\Windows Sidebar

taskkill /IM sidebar.exe /T /F

REM Fix for windows security update

pushd "%localappdata%\microsoft\windows live\services\cache"

IF EXIST ConfigOriginal.xml. (

     echo ConfigOriginal.xml file exists

) ELSE (

     copy Config.xml ConfigOriginal.xml

)

attrib "%localappdata%\microsoft\windows live\services\cache\*.xml" -r

del Config.xml

copy ConfigOriginal.xml Config.xml

echo. >> "Config.xml"

popd

REM Restart sidebar

pushd "%userprofile%\AppData\Local\Microsoft\Windows Sidebar"

xcopy /Y Settings3Monitors.ini Settings.ini

popd

start "" sidebar.exe

Tuesday 17 February 2015

Default Notepad++ to XML language sytnax highlighting for .config files

On the Notepad++ menu bar, click "Settings" -> "Styler Configurator..."

image
- Under "Language", select "XML"
- Under "User ext", type in "config".  While we're at it, let's also type in (space delimited) "aspx", "ascx", and "master".
- Click "Save & Close"

That's it!  Now when you view config files, ASP.NET pages, user controls, or master pages in Notepad++, you'll get syntax highlighting.

More about this here... http://www.mattblodgett.com/2007/11/notepad-tip-syntax-highlighting-for.html

Monday 16 February 2015

TFS Http 404 not found error

If you get an HTTP 404 not found error when connecting to TFS

clip_image002

Delete all the files in this folder

%userprofile%\AppData\Local\Microsoft\Team Foundation\4.0\Cache

You also may receive an error message in the VS 2013 output window, reading as follows...

We were unable to automatically populate your Visual Studio Online accounts.

The following error was encountered: One or more errors occurred.TF205020: Could not connect to server ‘tfs.russellreynolds.com\DefaultCollection’. This server was used in your last session, but it might be offline or unreachable. Confirm that the server is available on the network. To attempt to connect again, or to a different server, click ‘Connect To Team Foundation Server’ in Team Explorer or the Team menu.

The server returned the following error: HTTP code 404: Not Found

Wednesday 11 February 2015

Resharper running slowly

Just found a neat trick for speeding up the Ctrl+T navigation slowness against my solution with JetBrains Resharper 8.2

1. Clean out your cache folder for the solution...

%userprofile%\AppData\Local\JetBrains\ReSharper\v8.2\SolutionCaches

2. Resinstall Resharper

Monday 2 February 2015

MVC / Jquery unobtrusive validation

http://www.devtrends.co.uk/blog/the-complete-guide-to-validation-in-asp.net-mvc-3-part-1

Also for how do attach a new client side method to unobtrusive validation e.g.

jQuery.validator.unobtrusive.adapters.add(adapterName, [params], fn);

see this article...

http://bradwilson.typepad.com/blog/2010/10/mvc3-unobtrusive-validation.html

 

Note: For any element a in your <form>, you can do this to figure out what validation is attached to the containing <form> for that element...


$.data(a.form, "validator").settings.rules

e.g.

$.data(a.form, "validator").settings.rules.MiddleInitial
Object {maxlength: "1", __dummy__: true}

$.data(a.form, "validator").settings.messages.MiddleInitial
Object {maxlength: "The middle initial must be a single charater"}

Wednesday 14 January 2015

How to do data dash data- attributes in Razor

Answer: Use an underscore

In the cshtml view file definition when declaring the attributes in the new {} object class for the attributes, use data_mycustomdataattribute to render out data-mycustomdataattribute

@Html.Hidden("controlName", "valueHere", new { @data_mycustomdataattribute = "testing dash"})

This will render the following...

<input data-mycustomdataattribute="testing dash" id="controlName" name="controlName" type="hidden" value="valueHere">

How to find the last interactive logons in Windows using PowerShell

Use the following powershell script to find the last users to login to a box since a given date, in this case the 21st April 2022 at 12pm un...