Skip to content

Instantly share code, notes, and snippets.

@jasonsirota
jasonsirota / homepage-brief.java
Created November 12, 2012 20:29
homepage-brief
View view = client.getView("beer", "by_name");
Query query = new Query().setKey("Wrath").setIncludeDocs(true);
ViewResponse result = client.query(view, query);
System.out.printf("Query returned %s docs", result.size());
@jasonsirota
jasonsirota / homepage.java
Created November 12, 2012 20:27
homepage for matt
//instantiate the client
List<URI> uris = new LinkedList<URI>();
uris.add(URI.create("http://localhost:8091/pools"));
CouchbaseClient client = new CouchbaseClient(uris, "beer-sample", "");
//add a doc
String key = "beer_Wrath";
String value = "{'name':'Wrath','type':'beer','category':'Belgian and French Ale'}";
client.set(key, 0, value).get();
//Assembly 1: Example.Entities.dll (no assembly references at all)
namespace Example.Entities
{
//Customer does not implement interface
public class Customer
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
}
@jasonsirota
jasonsirota / wcfowin.cs
Created August 4, 2011 17:51
WCF OWIN
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading;
using System.Threading.Tasks;
#modeled on a kv store that can be swapped
#semantics are memcached protocol
require 'dalli'
class DB
def initialize(servers)
@dc = Dalli::Client.new(servers)
end
@jasonsirota
jasonsirota / BeginSendSocketTest.cs
Created June 1, 2011 03:16
BeginSend Socket Test Mon
/*
I have a piece of .NET code that uses Asynchronous sockets that I want to cross
compile and run on Mono, however, when I attempt to run it, the AsyncCallback for
the BeginSend never gets called. I've boiled down the problem to a very simple
example. The example does not ever hit the callback, I have tried the following
configurations:
OS: Ubuntu 10.10 (Maverick Meerkat)
Mono 2.8.2 using Nathan Bridgewater's install shell script
Mono 2.10.2 using Nathan Bridgewater's updated shell script
@jasonsirota
jasonsirota / asyncunittests.cs
Created March 6, 2011 04:43
use ManualResetEvent to block a current thread while waiting for a callback unit test
private const string key = "hello";
private const string stringValue = "world!";
private Exception exb;
private readonly KetchupClient cli = new KetchupClient(BuildConfiguration(), "default");
private readonly ManualResetEvent mre = new ManualResetEvent(false);
[Fact]
public void SetWithSuccess() {
//have to do this for async operations in unit test framework
Reset();
@jasonsirota
jasonsirota / listener.cs
Created January 10, 2011 02:03
ideas for message passing
public enum HostMessageEnum
{
SendRequestHeader,
SendRequestHeadersComplete,
SendRequestBodyStart,
SendRequestBodyPart,
SendRequestBodyComplete,
BeginGetResponse,
Error
}