Skip to content

Instantly share code, notes, and snippets.


Rob Reynolds ferventcoder

View GitHub Profile
idavis / Models.cs
Created July 6, 2011 22:33
Inverse null coalescing 'operator' support. Only properties are allowed.
View Models.cs
#region Using Directives
using System.Threading;
namespace ObjectExtensions.Tests
public class Person
KevM / Nuget.Config
Created January 19, 2012 23:19
Nuget configuraiton of package sources.
View Nuget.Config
<?xml version="1.0" encoding="utf-8"?>
<add key="disableSourceControlIntegration" value="true" />
<add key="myrepo" value="\\server\\share\\path" />
Iristyle / Bootstrap-EC2-Windows-CloudInit.ps1
Created January 24, 2012 20:38
Bootstrap Windows EC2 node with WinRM and CloudInit for making your own AMI
View Bootstrap-EC2-Windows-CloudInit.ps1
# Windows AMIs don't have WinRM enabled by default -- this script will enable WinRM
# AND install the CloudInit.NET service, 7-zip, curl and .NET 4 if its missing.
# Then use the EC2 tools to create a new AMI from the result, and you have a system
# that will execute user-data as a PowerShell script after the instance fires up!
# This has been tested on Windows 2008 R2 Core x64 and Windows 2008 SP2 x86 AMIs provided
# by Amazon
# To run the script, open up a PowerShell prompt as admin
# PS> Set-ExecutionPolicy Unrestricted
# PS> icm $executioncontext.InvokeCommand.NewScriptBlock((New-Object Net.WebClient).DownloadString(''))
Iristyle / gist:1776477
Created February 9, 2012 02:03
CloudInit.NET script for Windows Core 2008 R2 with IIS, .NET 4 and WebDeploy 2.0
View gist:1776477
#! /powershell/
Set-StrictMode -Version Latest
$log = 'c:\cloudfu.txt'
Add-Content $log -value "Initial Execution Policy: [$(Get-ExecutionPolicy)]"
Set-ExecutionPolicy Unrestricted
Add-Content $log -value "New Execution Policy: [$(Get-ExecutionPolicy)]"
Add-Content $log -value "Path variable [${env:Path}]"
Add-Content $log -value "PSModulePath variable [${env:PSModulePath}]"
bradwilson / InlineTask.targets.xml
Created March 11, 2012 00:41
Inline MSBuild task to download NuGet.exe
View InlineTask.targets.xml
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<OutputFilename ParameterType="System.String" Required="true" />
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
<Using Namespace="System" />
<Using Namespace="System.IO" />
View example.cs
var inputs = new[] { "", "", "", };
var results = await inputs.AsAsync()
.WhereAsync(async x => await IsPageInTop10WebSitesByTraffic(x))
.SelectAsync(async x => await DownloadPageAsync(x))
mseankelly / tweak
Created July 8, 2012 00:07
Subvert NuGet 2.0's insistence that the developer explicitly enable package restore.
View tweak
<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
<!--Update the file that is generated when you enable NuGet package restore with the following tweak.-->
<!--This will make it so that everyone pulling the project from source control will automatically pull the requisite NuGet packages the first time they build.-->
<!--While I understand why MS put this in place, it really doesn't make sense in the context of my current team (or any other team I've ever worked on).-->
<SetEnvironmentVariable EnvKey="EnableNuGetPackageRestore" EnvValue="true" Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' " />
<Exec Command="$(RestoreCommand)"
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
View 0HowAwesomeIsThis.cs
public class SomeClass {
public void SomeMethod() {
this.Log().Info(() => "Here is a log message with params which can be in Razor Views as well: '{0}'".FormatWith(typeof(SomeClass).Name));
xavierdecoster / register a myget feed.markdown
Last active July 12, 2022 12:43
Store MyGet credentials in your roaming user profile NuGet.config
View register a myget feed.markdown

Execute the following script using your MyGet [feedUrl] and MyGet [username] , [password] and [apikey]. Run this from a commandline where you have access to nuget.exe (or set the path to your nuget.exe in a system environment variable).

Store credentials in machine-level nuget.config (non-transferable)

nuget setapikey [apikey] -source [feedUrl]
nuget sources add|update -Name [name] -source [feedUrl] -User [username] -pass [password]
idavis / Regex.ps1
Created August 21, 2012 18:14
Ruby Style Regex Matching in Powershell
View Regex.ps1
function =~ {
param([regex]$regex, [switch]$debug, [switch]$caseSensitive)
process {
$matches = $null
$mached = $false
if($caseSensitive) {
$matched = $_ -cmatch $regex
} else {
$matched = $_ -match $regex