Skip to content

Instantly share code, notes, and snippets.

View lanwin's full-sized avatar
🤡
-

Steve Wagner lanwin

🤡
-
View GitHub Profile
@lanwin
lanwin / rabbit_based_message_bus.cs
Created February 14, 2012 08:30
This is an example how to use our Rabbit Service Bus.
/* Initialize bus. In this case via Autofac */
builder.RegisterModule(new RabbitModule
{
HostName = "localhost",
UserName = "user",
Password = string.Empty,
Exchanges = {
new Exchange("exchange1"){Durable=true;},
new Exchange("exchange2"){Durable=true;}
}
@lanwin
lanwin / objectdiff.cs
Created May 31, 2012 08:14
ObjectDiff to compare objects with checking if properties, fields, and arrays are the same
static class ObjectDiff
{
static IEnumerable<Member> GetMembers(object obj)
{
foreach(var propertyInfo in obj.GetType().GetProperties().Where(p => p.CanRead))
{
var info = propertyInfo;
yield return new Member
{
Name = info.Name,
@lanwin
lanwin / gist:2948383
Created June 18, 2012 13:30
ASP.Net WebApi: Answer text/html requests with application/json
public class JsonWithHtmlMediaTypeFormatter : JsonMediaTypeFormatter
{
public JsonWithHtmlMediaTypeFormatter()
{
SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
}
public override void SetDefaultContentHeaders(Type type, HttpContentHeaders headers, string mediaType)
{
base.SetDefaultContentHeaders(type, headers, mediaType);
@lanwin
lanwin / kudu_with_subdomain.patch
Created August 9, 2012 12:58
This patch extens Kudu to use the given app subdomains instead random ports with localhost for site bindings.
Kudu.SiteManagement/SiteManager.cs | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/Kudu.SiteManagement/SiteManager.cs b/Kudu.SiteManagement/SiteManager.cs
index 43a6012..87b466d 100644
--- a/Kudu.SiteManagement/SiteManager.cs
+++ b/Kudu.SiteManagement/SiteManager.cs
@@ -6,12 +6,15 @@
using System.Net.NetworkInformation;
using System.Threading;
@lanwin
lanwin / oom.cs
Created October 28, 2012 09:47
Raven Client 1.2.2127 OOM on inserting large amounts of data
public class OutOfMemoryTest
{
public void Run()
{
// client version 1.2.2127
using(var store = new DocumentStore
{
Url = "http://TestRaven:8080",
DefaultDatabase = "Test",
})
@lanwin
lanwin / gist:4124736
Created November 21, 2012 12:59
constructor function - but R# Name dose not match rule 'Local Variable'. Suggested name is app.
(function() {
"use strict";
// constructor function - but R# Name dose not match rule 'Local Variable'. Suggested name is app.
var App = function() {
// ...
};
ko.applyBindings(new App());
})();
@lanwin
lanwin / gist:4138801
Created November 24, 2012 07:39
Immutable type checking for Simon
class Mutable {
}
[Immutable]
public class ImmutableB
{
public readonly A = new ImmutableA();
}
@lanwin
lanwin / object_stream_merging.js
Created August 6, 2013 09:10
Nodejs merging object streams. Here is my current working example. But I dont like it. A MergeStream with one 'end' event would be much better. A sidenode: FeedParser implements node TransformStream and set its objectmode to true so that in the end we stream objects instead buffers. This could be better solved with RxJS. But what I currently don…
var data = [];
exampleFeeds.forEach(function(feedFile) {
fs.createReadStream(feedFile)
.pipe(new FeedParser())
.on('meta', function(meta) {
data.push(meta);
if(data.length===exampleFeeds.length){
console.log('done '+data.length);
// do something
}
@lanwin
lanwin / quote.txt
Last active December 25, 2015 11:49
Less types and more functions.
As lisp programmers have know for a long time it is better to have a smallish number of ubiquitous data types and a large number of small functions that work on them, than to have a large number of data types and a small number of functions that work on them.
@lanwin
lanwin / index.html
Created June 7, 2016 07:21
Redux devtools extension with mori
<!DOCTYPE html>
<html>
<body>
<script src="/node_modules/redux/dist/redux.js" type="text/javascript"></script>
<script src="/node_modules/mori/mori.js" type="text/javascript"></script>
<script type="text/javascript">
"use strict";
function reducer(){
return mori.hashMap('key','value');