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
[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")
@ChrisMissal
ChrisMissal / qunit-test-setup.js
Created December 9, 2009 21:35
I can't tell if this is ok, or could have some ugly consequences.
module("Some Module Name", {
setup: function() {
$("body").children(":not('.qunit-element')").remove();
}
});
internal struct Tag
{
private readonly string name;
private const string DEFAULT_TAG_NAME = "UnCategorized";
public Tag(string name)
{
this.name = name;
}
@ChrisMissal
ChrisMissal / linq.js
Created January 13, 2010 15:47 — forked from nkohari/linq.js
/*
linq.js -- a simple LINQ implementation for javascript
Author: Nate Kohari <nate@enkari.com>
Copyright (C) 2009 Enkari, Ltd.
Released under the Apache 2.0 license (http://www.opensource.org/licenses/apache2.0.php)
*/
Array.prototype.all = function(func) {
var result = true;
this.iterate(function(item) {
using (var txn = session.BeginTransaction())
{
try
{
session.SaveOrUpdate(entity);
session.Flush(); // <-- is this even necessary? UPDATE... Not necessary, thanks! :)
txn.Commit();
}
catch (HibernateException)
{