Skip to content

Instantly share code, notes, and snippets.

@danielwertheim
danielwertheim / Program.cs
Created September 16, 2015 14:10
ReleaseDebugInlining
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
namespace DebugVsRelease
{
class Constants
{
public const int Itterations = 1000000;
}
http://www.dustin.se/product/5010746863/sp-pov-buoy/
http://www.dustin.se/product/5010640729/sandisk-microsdxc-ultra-class-10-64-gb/
http://www.dustin.se/product/5010667590/gopro-hero3-black-edition/
http://www.dustin.se/product/5010672749/gopro-caps-doors-hero3/
@danielwertheim
danielwertheim / MyFactAttribute.cs
Created April 14, 2014 12:59
Custom xUnit attribute
public class MyFactAttribute : FactAttribute
{
public MyFactAttribute(params string[] scenarios)
{
if(!scenarios.Any() || IntegrationTestsRuntime.Environment.SupportsEverything)
return;
if (!scenarios.All(r => IntegrationTestsRuntime.Environment.HasSupportFor(r)))
Skip = string.Format("TestEnvironment does not support ALL test scenario(s): '{0}'.", string.Join("|", scenarios));
}
[Fact]
public void Can_search_on_default_index()
{
var searchRequest = new SearchIndexRequest(CloudantTestData.Views.Views101AnimalsSearchIndexId)
.Configure(q => q.Expression("kookaburra"));
var response = SUT.SearchAsync(searchRequest).Result;
response.Should().BeSuccessfulGet(numOfRows: 1);
response.Bookmark.Should().NotBeNullOrEmpty();
@danielwertheim
danielwertheim / gist:7037127
Last active December 25, 2015 20:39
Using MyCouch to consume CouchDb or Cloudant Changes
using System;
using System.Threading;
using MyCouch;
using MyCouch.Requests;
namespace Cloudant_Changes_Feature
{
class Program
{
static void Main(string[] args)
function(doc) {
if (doc.Type == "A") {
emit([doc.Week, doc.Day, 0]);
}
if (doc.Type == "B") {
emit([doc.Week, doc.Day, 1], doc.Class);
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Main2");
var ints = GetInts();
Console.WriteLine("Main2");
@danielwertheim
danielwertheim / fallvelocity.csx
Created August 12, 2013 12:45
Reading a book "Introducing Erlang". Simple comparison of a sample in there. Erlang vs C# in ScriptCS.
Func<double, double> fallVelocity = distance => System.Math.Sqrt(2 * 9.8 * distance);
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
@danielwertheim
danielwertheim / app.js
Last active March 21, 2017 19:30
Super simple SPA foundation thingie.
(function (exports) {
var app = exports.app = {
bindingContext: {
domnode: null,
model: null,
loadTemplate: function (templateName) {
return document.getElementById(templateName).innerHTML;
},
bind: function (templateName, vm) {
this.domnode.innerHTML = this.loadTemplate(templateName);