Skip to content

Instantly share code, notes, and snippets.

View mookid8000's full-sized avatar
💭
Pressing buttons.

Mogens Heller Grabe mookid8000

💭
Pressing buttons.
View GitHub Profile
@mookid8000
mookid8000 / gist:5036713
Last active December 14, 2015 05:39
RavenDB "transparent lazy load"
public class SomeDoc : Doc
{
public Ref<AnotherDoc> TheOtherDoc { get; set; }
}
public class AnotherDoc : Doc
{
public string Text { get; set; }
}
Configure.With(...)
.Transport(t => t.UseRabbitMq(...) //< giver en RabbitMqOptions
.PrefetchCount(5))
@mookid8000
mookid8000 / Imaginary Rebus API
Created January 21, 2013 13:05
Imaginary Rebus API
Configure.With(....)
.(....)
.Behavior(b => b.IgnoreUnhandledMessages())
@mookid8000
mookid8000 / gist:3964165
Created October 27, 2012 10:42
DrugLord.Messages
namespace DrugLord.Messages
{
public class MakeDeposit
{
public Money Money { get; set; }
public Drugs Drugs { get; set; }
public string SecretCode { get; set; }
}
public class Money
@mookid8000
mookid8000 / gist:3951079
Created October 25, 2012 07:11
SQL datareader
using(var conn = new SqlConnection("server=.;initial catalog=minDatabase;integrated security=sspi"))
{
conn.Open();
using(var cmd = conn.CreateCommand())
{
cmd.CommandText = "select something from whatever";
using(var reader = cmd.ExecuteReader())
{
@mookid8000
mookid8000 / gist:3849308
Created October 7, 2012 19:23
Rebus timeout example
These two can be in the same handler:
public void Handle(SomethingInteresting msg)
{
var correlationId = "possiblySomethingThatMakesSense";
bus.Send(new SomeMessageThatKicksOffSomeProcess { CorrelationId = correlationId });
bus.Defer(TimeSpan.FromMinutes(2), new VerifyThatAllExpectedRepliesWereReceived { CorrelationId = correlationId });
}
public void Handle(VerifyThatAllExpectedRepliesWereReceived msg)
@mookid8000
mookid8000 / gist:3829106
Created October 3, 2012 19:10
MongoDB query check
> use test
switched to db test
> db.coll.save({firstName: "Mogens", address:{street: "Torsmark"}})
> db.coll.find()
{ "_id" : ObjectId("506c8cbaac822bf4a75bd2c9"), "firstName" : "Mogens", "address" : { "street" : "Torsmark" } }
> db.coll.find({"firstName": "Mogens"})
{ "_id" : ObjectId("506c8cbaac822bf4a75bd2c9"), "firstName" : "Mogens", "address" : { "street" : "Torsmark" } }
> db.coll.find({"firstName": "Mogens", "address.street": "Torsmark"})
{ "_id" : ObjectId("506c8cbaac822bf4a75bd2c9"), "firstName" : "Mogens", "address" : { "street" : "Torsmark" } }
@mookid8000
mookid8000 / gist:3315202
Created August 10, 2012 15:56
Possible MSMQ subqueue thing for Rebus
Configure.With(adapter)
.Transport(t => t.UseMsmqWithSubqueues())
.CreateBus().Start();
//...
<!-- old style: -->
<!-- <rebus inputQueue="someExplicitlyStatedInputQueue" errorQueue="someExplicitlyStatedErrorQueue"> -->
<!-- subq style ('input' and 'error' automagically created beneath this name): -->
@mookid8000
mookid8000 / gist:2830338
Created May 29, 2012 19:55
StructureMap Rebus registry THAT DOES NOT WORK
public class SomeRegistry : StructureMap.Configuration.DSL.Registry
{
public SomeRegistry()
{
For<ISomething>().Singleton().Use<SomeImplementation>();
For<IDit>().Singletong().Use<Dat>();
// osv....
// og så:
begin transaction
delete 1000 rows
<---- why is it possibly for my other tx to get results about here?
insert bulk 1000 rows
commit transaction