Skip to content

Instantly share code, notes, and snippets.

View haacked's full-sized avatar
🏠
Code code code

Phil Haack haacked

🏠
Code code code
View GitHub Profile
@haacked
haacked / never-not.cs
Last active March 23, 2021 21:40
Weird roslyn waring
public interface IArgument
{
/// <summary>
/// The value of the argument sans quotes.
/// </summary>
string Value { get; }
}
public interface IArguments : IReadOnlyList<IArgument>, IArgument
{
@haacked
haacked / phil-bios.md
Last active January 13, 2021 16:28
Phil's Bios

I'm often asked to provide a bio such as when speaking. I hate writing them over and over so I keep this around.

Bio

Phil Haack is the founder and CEO of Haacked LLC where he coaches software organizations and helps them become the best versions of themselves.

To do this, Phil draws upon his experiences at GitHub where he was a director of engineering and helped make GitHub friendly to developers on the Microsoft platform.

He also draws upon his experience at Microsoft where he was a Senior Program Manager responsible for shipping ASP.NET MVC, NuGet, among other projects. These products had permissive open source licenses and ushered in Microsoft’s Open Source era.

@haacked
haacked / jsonconvert-bug.cs
Created June 8, 2020 00:00
JsonConvert Bug?
[Fact]
public void StackTest()
{
var stack = new Stack<string>();
stack.Push("one");
stack.Push("two");
stack.Push("three");
var serialized = JsonConvert.SerializeObject(stack, new JsonSerializerSettings
{
@haacked
haacked / LayoutForPartialTagHelperExample.md
Last active April 1, 2020 18:18
I would like a way to do this with the partial tag helper.

What I'm looking for is a nicer more declarative approach to Templated Razor Delegates

In Any old Razor Page or View - SomePage.cshtml

...
<div>
  <partial name="Shared/_PartialLayout" for="SomeModel">
    <strong>Content</strong> that will be injected into the layout, which 
 will get rendered here.
@haacked
haacked / code-review-checklist.md
Last active March 9, 2020 19:28
Code Review Checklist

General

  1. Unit tests: Review unit tests first. Unit tests are a fantastic way to grasp how code is meant to be used by others and to learn what the expected behavior is. Are there any test gaps that should be there?
  2. Method arguments" Make sure arguments to methods make sense and are validated. Mentally test boundary conditions and edge cases.
  3. Null References" (Yah yah, we know. Use F# and this goes away. We get it already.) Null references are a bitch and it’s worth looking out for them specifically.
  4. Conventions Consistency" Make sure naming, formatting, etc. follow our conventions and are consistent. I like a codebase that’s fairly consistent so you know what to expect.
  5. Disposables: Make sure disposable things are disposed. Look for usages of resources that should be disposed but are not.
  6. Security: There is a whole threat and mitigation review process that falls under this bucket. In simple terms, ask yourself how this code could be exploited. The [STRIDE Threat Mo
@haacked
haacked / RoleProfileService.cs
Last active September 18, 2019 15:25
Providing Role Claims
/*
This needs to be registered with the IdentityServer in the Startup.cs
by calling AddProfileService<RoleProfileService>() on the builder returned
by AddIdentityServer.
ex...
var builder = services.AddIdentityServer(options =>
{
options.Events.RaiseErrorEvents = true;
@haacked
haacked / index.js
Created February 9, 2019 20:49
Probot handler for the Why Not Both app
module.exports = (app) => {
// Respond to new issue comments
app.on('issue_comment.created', async context => {
const message = context.payload.comment.body
// The following does a rough approximation of
// trying to find a question that proposes two
// alternatives. It's not very smart about it,
// but good enough for our case.
const dichotomy = message.toLowerCase()

Keybase proof

I hereby claim:

  • I am haacked on github.
  • I am haacked (https://keybase.io/haacked) on keybase.
  • I have a public key whose fingerprint is BF14 9135 A9BB DB1E DF3B 0F27 51AC AFF3 A55E 8DE3

To claim this, I am signing this object:

@haacked
haacked / ThrowsAsync.cs
Created January 24, 2013 00:37
An async version of xUnit's Async.Throws. Use it like so: await ThrowsAsync<AuthenticationException>(async () => await obj.GetStuffAsync());
public async static Task<T> ThrowsAsync<T>(Func<Task> testCode) where T : Exception
{
try
{
await testCode();
Assert.Throws<T>(() => { }); // Use xUnit's default behavior.
}
catch (T exception)
{
return exception;
@haacked
haacked / reading-list.md
Last active February 24, 2017 21:44
A selection of articles and books that have inspired some of the topics in recent talks I've given.