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
// ---------------------------------------------------------------------------------------------- | |
// display control buttons to right of each list item on hover | |
// ---------------------------------------------------------------------------------------------- | |
var buttonMarkup = "<span class='btn-group'><a href='#' class='drag-handle btn'>" + | |
"<i class='icon-resize-vertical'></i></a>" + | |
"<a href='#' class='btn remove-item'><i class='icon-trash'></i></a></span>"; | |
$("#sortable") | |
.on("mouseenter", "li", function(e){$(this).append($(buttonMarkup))}) | |
.on("mouseleave", "li", function(e){$(this).find("span.btn-group").remove()} |
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 (var service = new PollServiceClient()) | |
{ | |
service.PollAsync(request, Poll_Completed); | |
} |
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
/// <summary> | |
/// Primality test of mersenne prime using the lucas-lehmer test | |
/// </summary> | |
/// <param name="p">A prime number</param> | |
/// <returns>true if 2^p-1 is prime, otherwise false</returns> | |
public static bool IsMersennePrime(int p) | |
{ | |
BigInteger mp = BigInteger.Pow(2, p) - 1; | |
BigInteger n = 4; | |
for (int i = 1; i < p - 1; i++) |
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 class ImmutableList<T> : IEnumerable<T> | |
{ | |
List<T> _items; | |
public ImmutableList() | |
{ | |
_items = new List<T>(); | |
} | |
private ImmutableList(List<T> items) |
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 class SquashPlayer | |
{ | |
public readonly string Name; | |
public readonly int Ranking; | |
public SquashPlayer(string name, int ranking) | |
{ | |
Name = name; | |
Ranking = ranking; | |
} |
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 static void Main(string[] args) | |
{ | |
string[] input = {"Ramy", "Gregory", "Willstrop", | |
"Matthew", "El Shorbagy", "Drakenberg", "Hult", "Friberg"}; | |
var players = new ImmutableList<SquashPlayer>(); | |
var rnd = new Random(); | |
var writer = new Thread( () => { | |
int i = 1; |
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 abstract class Command<M> where M : Model | |
{ | |
public virtual void Execute(M modelIn, out M modelOut) | |
{ | |
modelOut = null; | |
throw new NotImplementedException(); | |
} | |
public virtual void Execute(M Model) | |
{ |
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 class ActiveMqTopicClient : IDisposable | |
{ | |
public delegate void MessageReceivedHandler(IMessage message); | |
public event MessageReceivedHandler MessageReceived; | |
readonly IConnection _connection; | |
readonly ISession _session; | |
readonly IMessageProducer _producer; | |
readonly IMessageConsumer _consumer; | |
bool _isDisposed = false; |
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
[TestMethod] | |
public void separate_client_in_same_process_receives_message_using_null_selector_and_ignoring_local_messages() | |
{ | |
var topic = Guid.NewGuid().ToString(); | |
var host = "tcp://localhost:61616"; | |
var topicClient1 = new ActiveMqTopicClient(topic, host, ignoreLocal: true); | |
var topicClient2 = new ActiveMqTopicClient(topic, host, ignoreLocal: true); | |
var eventsRecieved = 0; | |
var waitHandle = new ManualResetEvent(initialState: false); |
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 Todo.Core | |
@{ | |
var listNames = Query(m => m.Lists.Select(list => list.Name).ToArray()); | |
} | |
<ul> | |
@foreach (var name in listNames) | |
{ | |
var tasks = Query(db => db.Lists.Single(list => list.Name == name) | |
.Tasks.Select(task => task.Title).ToArray()); | |