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 / gist:912552
Created April 10, 2011 17:36
Sample jQuery File
<!DOCTYPE html>
<html>
<head>
<title>Index</title>
<script src="../../Scripts/jquery-1.5.1.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("#form").validate({
rules: {
@haacked
haacked / utf-rt.cs
Created January 30, 2012 06:27
Round Tripping UTF-8
using System;
using System.Text;
class Program
{
static void Main(string[] args)
{
var data = new byte[] { 128 };
string text = Encoding.UTF8.GetString(data);
var bytes = Encoding.UTF8.GetBytes(text);
@haacked
haacked / windows-1252-roundtrip.cs
Created January 30, 2012 06:55
Windows-1252 Encoding Round Trip Demo
using System;
using System.Linq;
using System.Text;
class Program
{
static void Main(string[] args)
{
var encoding = Encoding.GetEncoding(1252);
for (int b = Byte.MinValue; b <= Byte.MaxValue; b++)
@haacked
haacked / creativity-inc-raw-notes.md
Created September 30, 2015 20:02
Raw notes from Creativity Inc. Someday I'll do something better with it. Someday.

Creativity, Inc.: Overcoming the Unseen Forces That Stand in the Way of True Inspiration

Ed Catmull, Amy Wallace

When it comes to creative inspiration, job titles and hierarchy are meaningless.

Sincerely believing that we were in an inclusive meeting, we saw nothing amiss because we didn’t feel excluded.

My willingness to do this reflected my world-view, forged in academia, that any hard problem should have many good minds simultaneously trying to solve it.

For all the care you put into artistry, visual polish frequently doesn’t matter if you are getting the story right.

@haacked
haacked / continue-after-unit-tests.cs
Created October 8, 2012 22:34
ContinueAfter Unit Tests
public class TheContinueAfterMethod
{
[Fact]
public void RunsNextItemAfterCompletion()
{
var stringSequence = new[] { "one", "two", "three" }.ToObservable();
var observed = new List<String>();
Observable.Return(123).ContinueAfter(() => stringSequence)
.Subscribe(observed.Add);
@haacked
haacked / diff-tree-output
Created February 22, 2014 19:05
git diff-tree --cc cc5b002a on signalr/signalr
cc5b002a5140e2d60184de42554a8737981c846c
diff --cc tests/Microsoft.AspNet.SignalR.FunctionalTests/Client/HubProxyFacts.cs
index aaad4c4,8bf42fc..4979ab7
--- a/tests/Microsoft.AspNet.SignalR.FunctionalTests/Client/HubProxyFacts.cs
+++ b/tests/Microsoft.AspNet.SignalR.FunctionalTests/Client/HubProxyFacts.cs
@@@ -36,11 -36,9 +37,11 @@@ namespace Microsoft.AspNet.SignalR.Test
hubConnection.Start(host.Transport).Wait();
- proxy.Invoke("Send", "hello").Wait();
@haacked
haacked / encouragements.txt
Created August 6, 2014 21:45
My Encouragements
😱 Seriously?
😷 That's a bad look.
Burn it to the ground! 🔥
😠 Torvalds frowns at you.
🚶 Have you considered another career?
You must hate your coworkers. 👹
😡 You must hate yourself.
Ha! Yeah, that'll work. 😄
😕 Are you just hitting keys at random?
You code like a PM. 😐
@haacked
haacked / GetLoadableTypes.cs
Created January 5, 2013 22:14
Method to return all loadable types in an assembly. See [this blog post](http://haacked.com/archive/2012/07/23/get-all-types-in-an-assembly.aspx) for details.
public static IEnumerable<Type> GetLoadableTypes(this Assembly assembly)
{
if (assembly == null) throw new ArgumentNullException("assembly");
try
{
return assembly.GetTypes();
}
catch (ReflectionTypeLoadException e)
{
return e.Types.Where(t => t != null);
public sealed class Dependency : IDisposable
{
public string SomeProperty { get; set; }
public void Dispose()
{
}
}
public sealed class Owner : IDisposable
@haacked
haacked / Async-Lambda.cs
Created January 24, 2013 00:03
Example usage of an async lambda.
Assert.Throws<SomeException>(async () => await obj.GetAsync());