Skip to content

Instantly share code, notes, and snippets.

View ferventcoder's full-sized avatar
🎯
Focusing

Rob Reynolds ferventcoder

🎯
Focusing
View GitHub Profile
@idavis
idavis / Models.cs
Created July 6, 2011 22:33
Inverse null coalescing 'operator' support. Only properties are allowed.
#region Using Directives
using System.Threading;
#endregion
namespace ObjectExtensions.Tests
{
public class Person
{
@KevM
KevM / Nuget.Config
Created January 19, 2012 23:19
Nuget configuraiton of package sources.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
<packageSources>
<add key="myrepo" value="\\server\\share\\path" />
</packageSources>
</configuration>
@Iristyle
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
# 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('https://raw.github.com/gist/1672426/Bootstrap-EC2-Windows-CloudInit.ps1'))
@Iristyle
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
#! /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
bradwilson / InlineTask.targets.xml
Created March 11, 2012 00:41
Inline MSBuild task to download NuGet.exe
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<OutputFilename ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
<Using Namespace="System" />
<Using Namespace="System.IO" />
var inputs = new[] { "http://www.google.com", "http://www.yahoo.com", "http://www.aol.com", };
var results = await inputs.AsAsync()
.WhereAsync(async x => await IsPageInTop10WebSitesByTraffic(x))
.SelectAsync(async x => await DownloadPageAsync(x))
.GetResults();
@mseankelly
mseankelly / NuGet.target tweak
Created July 8, 2012 00:07
Subvert NuGet 2.0's insistence that the developer explicitly enable package restore.
<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
<!--Update the NuGet.target 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)')" />
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
xavierdecoster / register a myget feed.markdown
Last active July 12, 2022 12:43
Store MyGet credentials in your roaming user profile NuGet.config

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
idavis / Regex.ps1
Created August 21, 2012 18:14
Ruby Style Regex Matching in Powershell
function =~ {
param([regex]$regex, [switch]$debug, [switch]$caseSensitive)
process {
$matches = $null
$mached = $false
if($caseSensitive) {
$matched = $_ -cmatch $regex
} else {
$matched = $_ -match $regex
}