Skip to content

Instantly share code, notes, and snippets.

@JohannesRudolph
JohannesRudolph / SimpleSpec.cs
Last active August 29, 2015 14:03
SubSpec with nested Lambdas. Need to find a better name.
// MS-PL License.
// Author Johannes Rudolph <jojo.rudolph@gmail.com>
// This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.
// 1. Definitions
// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law.
// A "contribution" is the original software, or any additions or changes to the software.
// A "contributor" is any person that distributes its contribution under this license.
// "Licensed patents" are a contributor's patent claims that read directly on its contribution.
@JohannesRudolph
JohannesRudolph / AutoIndexFailsRepro.cs
Created February 9, 2015 11:39
AutoIndexFailsRepro
public class AutoIndexMerging : RavenTest
{
const string SampleLogfileStoreId = "123";
[Fact]
public async Task AutoIndexReuseFails()
{
var store = NewRemoteDocumentStore( fiddler: true );
var session = store.OpenAsyncSession();
import rescala._
import rescala.events.{ Event, ImperativeEvent }
import makro.SignalMacro.{SignalM => Signal}
object ReScalaDemo extends App {
/*
Observer criticism
- inverts natural dependency order (listeners call soure to register)
@JohannesRudolph
JohannesRudolph / gist:1006783640ac06840787
Last active August 29, 2015 14:25
Some Scala Basics
object PathDependentTypes extends App {
class Food {}
class Grass extends Food {}
class DogFood extends Food {}
abstract class Animal {
// SuitableFood is a subtype of Food, deriving classes must define it
type SuitableFood <: Food
def eat(food: SuitableFood)
}
using System;
using Library;
using System.Reflection;
using System.Runtime.Remoting.Proxies;
using System.Runtime.Remoting.Services;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting.Activation;
namespace Library
{
var spec = from sut in SpecificationExpression.Begin(() => new Stack<int>())
where sut.Push(element)
select new Observations()
{
() => Assert.NotEmpty(sut),
() => Assert.Equal(element, sut.Peek())
};
@JohannesRudolph
JohannesRudolph / BoundedWildcards.java
Created March 25, 2011 08:12
A simple example showing common usage scenarios of bounded wildcards in java
class Vehicle {}
class Car extends Vehicle {}
class Porsche extends Car {}
public void foo(List<? extends Car> extendsCar , List<? super Car> superOfCar, List<Car> cars) {
Vehicle V = new Vehicle();
Car C = new Car();
Porsche P = new Porsche();
// [] specifies the range of valid types for ?
@JohannesRudolph
JohannesRudolph / TeamCityAdapter.m
Created May 27, 2011 08:53
TeamCity Adapter for SenTestingKit/OCUnit
//
// TeamCityAdadpter.m
// Created by Johannes Rudolph on 27.05.11.
// Use of this source code is governed by the following license:
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// (1) Redistributions of source code must retain the above copyright notice,
@JohannesRudolph
JohannesRudolph / gist:4193650
Created December 3, 2012 08:30
F# Cond Zip
open System.Linq
let a = [0; 5; 10]
let b = [0 .. 10]
// enumerates left and yields element pairs combined by consuming right until 'consume' is false or either sequence is exhausted
let condZip (left:seq<'a>) (right:seq<'b>) consume project =
seq {
use en = right.GetEnumerator()
let hadNext = ref(en.MoveNext())
@JohannesRudolph
JohannesRudolph / Demo.cs
Created December 20, 2012 17:39
Simple spec. A minimalisitic specification framework for xunit.net. MS-PL License.
using SimpleSpec;
using System;
using System.Collections.Generic;
using System.Linq;
using Xunit;
namespace SimpleSpec.Tests
{
public class Demo
{