Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View jbogard's full-sized avatar

Jimmy Bogard jbogard

View GitHub Profile
C:/Ruby192/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:753:in `read': Invalid argument - <internal:lib/rubygems/custom_require> (Errno::EINVAL)
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:753:in `inline_templates='
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:706:in `set'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:715:in `block in enable'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:715:in `each'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra/base.rb:715:in `enable'
from (__DELEGATE__):2:in `enable'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/sinatra-1.0/lib/sinatra.rb:7:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:33:in `require'
<ul>
<% (1..25).each do |i|
num = "%03d" % i
%>
<li><a href='/gallery/<%= num %>.jpg'><img src="/gallery/<%= num %>small.jpg" alt="" /></a></li>
<% end %>
</ul>
@jbogard
jbogard / Fun with LINQ aggregate.cs
Created February 11, 2011 20:01
I don't know why I find this so cool...
public string CombinePath(string path1, string path2, params string[] additionalPaths)
{
return additionalPaths.Aggregate(Path.Combine(path1, path2), Path.Combine);
}
@jbogard
jbogard / DisposableCollection.cs
Created June 9, 2011 14:15
Disposable Collection
public class DisposableCollection : ReadOnlyCollection<IDisposable>, IDisposable
{
public DisposableCollection(params IDisposable[] list) : base(list)
{
}
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
@jbogard
jbogard / gist:1233284
Created September 21, 2011 20:56
Supporting SL4 in AutoMapper
[TestFixture]
#if SILVERLIGHT
[Ignore("Not supported in Silverlight 4")]
#endif
@jbogard
jbogard / gist:1252482
Created September 30, 2011 02:06
Conditional crazy
object IMappingEngineRunner.CreateObject(ResolutionContext context)
{
var typeMap = context.TypeMap;
var destinationType = context.DestinationType;
if (typeMap != null)
if (typeMap.DestinationCtor != null)
return typeMap.DestinationCtor(context.SourceValue);
else if (typeMap.ConstructDestinationUsingServiceLocator && context.Options.ServiceCtor != null)
return context.Options.ServiceCtor(destinationType);
@jbogard
jbogard / RavenController.cs
Created November 28, 2011 16:50
Raven Controller
using System;
using System.Web.Mvc;
using Raven.Client;
using TekPub.Profiler.BackOffice.Tasks;
namespace TekPub.Profiler.BackOffice.Controllers
{
public class RavenController : Controller
{
protected IDocumentSession documentSession;
public class RavenDbMessageModule : IMessageModule
{
private readonly IDocumentStore documentStore;
[ThreadStatic]
private static IDocumentSession currentSession;
public static IDocumentSession CurrentSession
{
get { return currentSession; }
public class SimpleUnitOfWorkBehaviour : IActionBehavior
{
readonly IFubuRequest _fubuRequest;
readonly ISessionFactory _sessionFactory;
ISession _session;
public IActionBehavior InnerBehavior { get; set; }
public SimpleUnitOfWorkBehaviour(ISessionFactory sessionFactory,
IFubuRequest fubuRequest)
public void Invoke()
{
_fubuRequest.Set(new Lazy<ISession>(() =>
_session ?? (_session = CreateTransactionalSession())));