Skip to content

Instantly share code, notes, and snippets.

View ChrisMissal's full-sized avatar
💭
set status

Chris Missal ChrisMissal

💭
set status
View GitHub Profile
@ChrisMissal
ChrisMissal / ImplicitCausingNullRef.cs
Created April 10, 2014 18:47
Implicit operator causing sneaky NullReferenceException
void Main()
{
var order = new Order
{
Instructions = SpecialInstructions.LeaveAtDoor,
};
var thing = new Thing
{
Instructions = order.Instructions,
begin transaction
create table DumbSample (
Expired bit default 0,
Name varchar(max)
)
insert into DumbSample (Expired, Name) values (0, 'Milk');
@ChrisMissal
ChrisMissal / clitests.cs
Last active August 29, 2015 14:17
CLI Code Spike – Rethinking how I interact with the command line via C# a little bit. I have some spike code in which all these tests pass. Thoughts?
public class CommandResolutionTests
{
public void should_resolve_text_to_command()
{
"samplecommand".Called<SampleCommand>();
}
public void should_call_command_hello()
{
"samplecommand hello".Called<SampleCommand>()
@ChrisMissal
ChrisMissal / mat-quote-from-txjs.md
Last active August 29, 2015 14:27
The Once & Future Web: Mat Marquis

I love this quote by Mat Marquis from TXJS 2015:

We, as an industry, have nearly decided that we are all doing a really, really good job as long as we don't count the instances where we're doing a really, really bad job.

Source: https://www.youtube.com/watch?v=WZAx3f0nJS0

[DebuggerStepThrough]
public static void ForEach<T>(this IEnumerable<T> items, Action<T> processor)
{
foreach (var item in items)
{
processor(item);
}
}
@ChrisMissal
ChrisMissal / Attendee.cs
Created August 19, 2009 03:31
A simple NH mapping that is not working. Seems to be a cascade/delete issue.
namespace CRIneta.Web.Core.Domain
{
public class Attendee
{
protected readonly string email;
protected readonly Meeting meeting;
protected readonly int attendeeId;
protected Attendee()
{
public static Int32 GetChainLength(Int32 value)
{
Func<Int32, Int32> a = n => n / 2;
Func<Int32, Int32> b = n => 3 * n + 1;
Int32 chainLength = 1;
Int32 x = value;
while(x > 1)
{
x = (x > 1 && x % 2 == 0) ? a(x) : b(x);
function createMenu(desk) {
var createMenuItem = function(text, className) {
return $("<div/>").html(text).addClass("clickable").addClass(className).hide();
};
desk.append(createMenuItem('Trouble', 'troubleFlag'));
desk.append(createMenuItem('Leader', 'leaderFlag'));
}
@ChrisMissal
ChrisMissal / ternaryFunction.js
Created October 18, 2009 22:49
using a ternary operator to call one of two functions
// One of the reasons I like JavaScript:
function toggleTrait(trait, iconName) {
// some ugly code :)
((hasTrait) ? addIcon : removeIcon)(iconBar, iconName);
}
function addIcon(iconBar, iconName) {
iconBar.append($("<img/>").attr("src", "img/" + iconName + ".png"));
}
function removeIcon(iconBar, iconName) {
public static class IoC
{
private static readonly Container container;
static IoC()
{
container = new Container(x =>
{
x.ForConcreteType<OrderFilter>()
.Configure.WithCtorArg("connectionString")