Skip to content

Instantly share code, notes, and snippets.

View Porges's full-sized avatar
🏠
Working from home

George Pollard Porges

🏠
Working from home
View GitHub Profile
@Porges
Porges / AAA.txt
Last active August 29, 2015 14:21
Testing in Haskell
Using cabal to install quickcheck:
Make a directory to work in.
Inside the directory: “cabal sandbox init”
Then: “cabal install quickcheck”
You can open the GHCI repl in the sandbox:
"cabal repl"
And use normal commands like ":load filename.hs"
public IObservable<T> ExecuteQuery<T>(TableQuery<T> query, TableRequestOptions requestOptions = null, OperationContext operationContext = null) where T : ITableEntity, new()
{
return Observable.Create<T>(
async (observer, ct) =>
{
var tableToken = new TableContinuationToken();
while (tableToken != null)
{
var results = await ExecuteQuerySegmented(query, tableToken, requestOptions, operationContext, ct);
foreach (var result in results)
listContainers :: HTTP.Manager -> AccountName -> P.Producer ByteString IO ()
listContainers manager account = do
req <- P.lift $ fillOutTemplate template -- does some IO to fill out the request
let req' = Auth.signRequest account req
join $ P.lift $ HTTP.withHTTP req' manager $ \resp ->
return (P.for (HTTP.responseBody resp) P.yield)
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE KindSignatures #-}
import GHC.Exts (Constraint)
data Exists (t :: * -> Constraint) = forall a. t a => Exists a
using System;
using System.Threading;
using System.Threading.Tasks;
namespace AsyncCLI
{
public sealed class Program
{
// Main handles command line parsing and invocation
// of strongly-typed main method.
-- from https://gist.github.com/anonymous/83b1f8d2da6ee35d172b
import Data.Bits ((.&.), shiftR)
import Data.Char (chr)
import Data.Ratio ((%), Ratio, numerator)
import Data.Word (Word32)
poly :: Ratio Integer -> Ratio Integer
poly x =
- 74101463560860539810482394216134472786413399%404009590666424903383979388988167534591844018460526499864038804741201731572423877094984692537474105135297393596654648304117684895744000000000000000000000*x^99
@Porges
Porges / counts.cpp
Last active January 11, 2016 19:53
#include "stdafx.h"
#include <atomic>
#include <iostream>
#include <mutex>
#include <typeindex>
#include <typeinfo>
#include <unordered_map>
// here is the global mapping of type -> counts:
using System;
namespace Foob
{
interface IEater
{
void Eat();
bool CanEat { get; }
}
@Porges
Porges / FakeIO.fs
Last active December 15, 2015 23:32
A simple way to test IO-using functions
open System
module IOMonad =
// wooh, naming conventions!
// this is the interface for our IO implementations
type IIO =
abstract member printLineImpl : string -> unit
abstract member getLineImpl : unit -> string
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeOperators #-}
data HList :: [*] -> * where
HNil :: HList '[]
HCons :: a -> HList k -> HList (a ': k)