This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ls |% { pushd $_; ls *.zip |%{ Expand-Archive $_; rm $_} popd } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ActionResult Record(int id) | |
{ | |
Record record = repository.Load(id); | |
var viewModel = new { record.Id, record.Name, record.Description, record.Url /* etc. */ }; | |
return View(viewModel); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write a function that returns true or false depending on whether its input integer is a leap year or not. | |
A leap year is divisible by 4, but is not otherwise divisible by 100 unless it is also divisible by 400. | |
2001 is a typical common year | |
1996 is a typical leap year | |
1900 is an atypical common year | |
2000 is an atypical leap year |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestFixture] | |
public class LeapYearCalculatorAcceptanceTests | |
{ | |
[Test] | |
public void TestThat_IsLeapYear_ShouldReturnTrue_WhenTheGivenYearIsATypicalLeapYear() | |
{ | |
const int typicalLeapYear = 1996; | |
var isLeapYear = LeapYearCalculator.IsLeapYear(typicalLeapYear); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static bool IsLeapYear(int year) | |
{ | |
return true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public string GetPrettyPrintedJson(string json) | |
{ | |
dynamic parsedJson = JsonConvert.DeserializeObject(json); | |
return JsonConvert.SerializeObject(parsedJson, Formatting.Indented); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-ScriptDirectory { | |
$invocation = (Get-Variable MyInvocation -Scope 1).Value | |
$script = [IO.FileInfo] $invocation.MyCommand.Path | |
if ([IO.File]::Exists($script)) { | |
return (Split-Path $script.Fullname) | |
} else { | |
return $null | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static readonly IEnumerable<Foo> BaseCollectionOfFoo = new List<Foo> | |
{ | |
new Foo(1), | |
new Foo(2), | |
new Foo(3) | |
}; | |
private static readonly IEnumerable<Foo> AllFoo = new List<Foo>(BaseCollectionOfFoo) | |
{ | |
new Foo(4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var session = documentStore.OpenSession()) | |
{ | |
session.Load<Concert>(1) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param([string]$XenServerPoolMaster) | |
Add-PSSnapIn XenServerPSSnapin | |
. ".\credentials.ps1" | |
. ".\teamcity.ps1" | |
Connect-XenServer -Server $XenServerPoolMaster -Creds (Get-XenServerCredential) -NoWarnNewCertificates -NoWarnCertificates | |
Get-XenServer:VM -Server $XenServerPoolMaster |? { $_.tags -contains 'active' } |? { $_.name_label -ne $env:COMPUTERNAME } |% { |
OlderNewer