This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"strings" | |
) | |
func main() { | |
text := "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras " + | |
"venenatis, quam et dapibus porttitor, nisi mauris maximus sapien, a " + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
# choose() is the same as computing the number of combinations. Normally this is | |
# equal to: | |
# | |
# factorial(N) / (factorial(m) * factorial(N - m)) | |
# | |
# but this is very slow to run and requires a deep stack (without tail | |
# recursion). | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPost] | |
public HttpResponseMessage CreateCustomer(string name, string billingInfo) | |
{ | |
Result<BillingInfo> billingInfoResult = BillingInfo.Create(billingInfo); | |
Result<CustomerName> customerNameResult = CustomerName.Create(name); | |
return Result.Combine(billingInfoResult, customerNameResult) | |
.OnSuccess(() => _paymentGateway.ChargeCommission(billingInfoResult.Value)) | |
.OnSuccess(() => new Customer(customerNameResult.Value)) | |
.OnSuccess( |
I'm using this Vagrantfile
to run Kafka on a Windows 8.1 laptop for development purposes.
It runs the ultra-lightweight boot2docker Linux, then uses Vagrant's Docker provisioning support to spin up ZooKeeper and Kafka.
The fun bits to work out were:
- You need to forward the ports on both Vagrant (lines 13 & 14) and Docker (the
-p
flag), so you can access the instance from Windows usinglocalhost:9092
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
I wasn't able to find a single example on how to actually use Dapper's new TVP, so I though I'd add one. | |
First of all, you will need to install the Dapper.TVP package from NuGet. | |
The main item to note is the need to create and populate a list of SqlDataRecords. This is then used to used as part of the | |
input parameter for Dapper's TableValueParameter. | |
The API is thus: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum Cacheability | |
{ | |
NoCache, | |
Private, | |
Public, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using Nancy.ModelBinding; | |
public class DynamicModelBinder : IModelBinder | |
{ | |
public object Bind(NancyContext context, Type modelType, object instance, BindingConfig configuration, params string[] blackList) | |
{ | |
var data = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Data; | |
using System.Data.SqlClient; | |
using System.Threading; | |
namespace SqlDependencyConcurrency | |
{ | |
class Program | |
{ | |
private static readonly string _connectionString = "Data Source=(local);Initial Catalog=Sample;Integrated Security=SSPI;"; |
NewerOlder