Skip to content

Instantly share code, notes, and snippets.

View half-ogre's full-sized avatar

Drew Miller half-ogre

View GitHub Profile

Lenten Potato and Leek Soup

This is a Lenten recipe, so it doesn't have any dairy. This is not how I would make a potato and leek soup outside of Lent.

Ingredients

  • 1 tbsp olive oil
  • 2 large leeks
  • 2 medium russet potatoes, diced
  • 2 medium golden Yukon potatoes, diced
  • 2 quarts good vegetable stock
@half-ogre
half-ogre / NuGet.targets.xml
Created February 22, 2012 04:22
A replacement for the NuGet.targets file that requires nuget.exe be on the path, so you don't have to commit it.
<?xml version="1.0" encoding="utf-8"?>
<!-- #### NOTE #### -->
<!-- To build with Mono's xbuild on bash, you must execute [`sudo install-nuget.sh`](https://gist.github.com/2595337) first. -->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
<!-- Windows specific commands -->
@half-ogre
half-ogre / gist:1873956
Created February 21, 2012 05:27
Fix for NuGet Gallery #417
var allPackageVersions = packagesQuery.ToList();
var packageVersions = allPackageVersions; ;
if (String.IsNullOrEmpty(version) && !allowPrerelease)
{
// If there's a specific version given, don't bother filtering by prerelease. You could be asking for a prerelease package.
packageVersions = packageVersions.Where(p => !p.IsPrerelease).ToList();
}
@half-ogre
half-ogre / gist:1803665
Created February 11, 2012 19:10
Accessing Node's module cache to build a collection of event processors
// My app uses event sourcing, and I need a collection of all the app's event processors.
// I don't want to maintain this collection by hand, changing every time I add a new processor.
// So, I build up the collection dynamically when the app starts by examining the module cache.
// Caveat: I have no idea whether accessing `require.cache` is supported.
// Note: An event processor is any exported constructor function that ends with 'EventProcessor'.
exports.buildEventProcessorCollection = function() {
var eventProcessors = { };
for (var id in require.cache) {
var mod = require.cache[id];
@half-ogre
half-ogre / gist:1766344
Created February 8, 2012 07:12
Pitch for my NoQA talk

NoQA: Context-Driven Testing for Doers

My contention: if you have dedicated testers, you're (probably) doing it wrong. Instead of having separate developers, testers, and project managers, just have one role: doers. I see more and more teams switching to role-less craftsmen; that's good, but I often see these teams struggle when deciding who tests what, and how. My goals for this talk, then, are to first convince you to do away with dedicated testers, and then to prepare you to do so susccessfully (as well as anyone can prepare you for such an undertaking in an hour's time).

@half-ogre
half-ogre / gist:1488735
Created December 17, 2011 00:58
A sample Sing-Along event handler
on :say do
nick, text = connection[:nick], data[:text]
raise NickRequiredError if nick.nil?
broadcast :said, { :nick => nick, :text => text }
end
@half-ogre
half-ogre / delete_package_registration.sql
Created December 8, 2011 21:27
Deleting a package registration directly in the database
use NuGetGallery
BEGIN TRAN
DECLARE @PackageRegistrationId nvarchar(max)
SET @PackageRegistrationId = '<id>'
ALTER TABLE GallerySettings NOCHECK CONSTRAINT ALL
DELETE FROM PackageStatistics
var linksArray = DomUtils.getElementsByTagName("link", item.children, false);
var entryLink = linksArray[0].attribs.href;
for (var i = 0; i < linksArray.length; i++) {
var linkRel = linksArray[i].attribs.rel.toLowerCase();
if (linkRel === 'alternate') {
entryLink = linksArray[i].attribs.href;
break;
}
}
entry.link = entryLink;
@half-ogre
half-ogre / CreateUrlHelperToFakeIsLocalUrl
Created July 3, 2011 08:02
It is way too hard to fake a call to Controller.Url.IsLocalUrl, which means I failed as a tester that day.
public static UrlHelper CreateUrlHelperToFakeIsLocalUrl(string fakeRequestUrl)
{
var httpContextBase = new Mock<HttpContextBase>();
httpContextBase.Setup(x => x.Request.Url).Returns(new Uri(fakeRequestUrl));
var requestContext = new RequestContext(httpContextBase.Object, new RouteData());
return new UrlHelper(requestContext);
}
// controller.Url = CreateUrlHelperToFakeIsLocalUrl("http://aFakeHost/aFakePage");
@half-ogre
half-ogre / Get-SaltedHash.ps1
Created January 26, 2011 04:27
I often need to get a hash with a random salt (usually for passwords) for the projects I work on. This is the PS script I use.
function Get-SaltedHash {
param($text)
$csp = new-object System.Security.Cryptography.RNGCryptoServiceProvider
$hashAlgorithm = new-object System.Security.Cryptography.SHA256Managed
$saltBytes = new-object byte[] 8
$csp.GetNonZeroBytes($saltBytes)
$textBytes = [System.Text.Encoding]::UTF8.GetBytes($text)