Skip to content

Instantly share code, notes, and snippets.

View halter73's full-sized avatar

Stephen Halter halter73

  • Microsoft
  • Kirkland, WA
View GitHub Profile
@halter73
halter73 / Poker.hs
Created December 21, 2010 20:55
Haskell solution the Project Euler Problem 54
module Poker (Value(..), Suit(..), Card(..), Hand, hand) where
import Control.Exception
import Data.List
data Value = Two | Three | Four | Five | Six | Seven | Eight | Nine | Ten
| Jack | Queen | King | Ace deriving (Eq, Ord, Bounded, Enum, Show)
data Suit = Clubs | Diamonds | Hearts | Spades deriving (Eq, Show)
data Card = Card {val :: Value, suit :: Suit} deriving (Eq, Show)
data HandType = HighCard
numSquares' n x y acc
| x > y = acc
| x*x + y*y > n = numSquares' n x (y-1) acc
| x*x + y*y == n = numSquares' n (x+1) (y-1) (acc+1)
| otherwise = numSquares' n (x+1) y acc
numSquares n = numSquares' n 0 (floor . sqrt . fromIntegral $ n) 0
main = interact $ unlines . map (show . numSquares . read) . tail . lines
@halter73
halter73 / gist:1129202
Created August 6, 2011 09:06
Weird continuation behavior (to me...)
#lang racket
;; Since the control-state blows itself away after the first call by
;; set!ing itself to a continuation, I would expect the return argument to
;; control-state to retain the value from it's first call. Therefore I
;; expected that calls subsequent to the first call to control state would
;; "return" execution back to the first call creating an infinite loop of
;; sorts, but in DrRacket 5.1 it outputs 0 1 and finishes execution.
;; [LISTOF X] -> ( -> X u 'you-fell-off-the-end)
@halter73
halter73 / HubPipeline.cs
Created October 6, 2012 03:36
New Hub Pipeline
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace SignalR.Hubs
{
public class HubPipeline : IHubPipeline, IHubPipelineInvoker
{
Func<int[], string> toRanges = source => source.Length == 0 ? "" :
String.Join(",", source.Skip(1).Aggregate(Enumerable.Repeat(Tuple.Create(source[0], source[0]), 1),
(combined, i) => combined.Last().Item2 == i - 1 ?
combined.Take(combined.Count() - 1).Concat(new[] { Tuple.Create(combined.Last().Item1, i) }) :
combined.Concat(new[] { Tuple.Create(i, i) })
).Select(range => range.Item1 == range.Item2 ? range.Item1.ToString() : range.Item1 + "-" + range.Item2));

Title

A short description of the bug that becomes the issue title
e.g. Long polling transport tries reconnecting forever when ping succeeds but poll request fails*

Any functional impact

Does the bug result in any actual functional issue, if so, what?
e.g. If poll request starts working again, it recovers. Otherwise, it sends many requests per sec to the servr.

Minimal repro steps

What is the smallest, simplest set of steps to reproduce the issue. If needed, provide a project that demonstrates the issue.

using System;
using System.Diagnostics;
using System.Numerics;
namespace ConsoleApp1
{
public class Program
{
public void Main(string[] args)
{
@halter73
halter73 / Program.cs
Created October 28, 2016 00:20
PeekLong Benchmark
using System;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Attributes;
using Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure;
namespace ConsoleApp2
{
public class Program
{
private static MemoryPool _pool;
> dotnet .\bin\Debug\netcoreapp1.0\service-b.dll
dbug: Microsoft.AspNetCore.Hosting.Internal.WebHost[3]
Hosting starting
dbug: Microsoft.AspNetCore.Hosting.Internal.WebHost[4]
Hosting started
Hosting environment: Production
Content root path: C:\Users\shalter\dev\stepro\sample-app\service-b\bin\Debug\netcoreapp1.0
Now listening on: http://*:80
Application started. Press Ctrl+C to shut down.
dbug: Microsoft.AspNetCore.Server.Kestrel[1]
interface ITransportFactory
{
ITransport Create(ListenOptions, IConnectionHandler);
}
interface ITransport
{
// Can only be called once per ITransport
Task BindAsync();
Task UnbindAsync();