Skip to content

Instantly share code, notes, and snippets.

View cbilson's full-sized avatar

Chris Bilson cbilson

View GitHub Profile
function Hello($name) {
"Hello, $name, from included file."
}
namespace StupidExample {
public class CustomerGateway {
IUnitOfWorkManager work;
public CustomerGateway(IUnitOfWorkManager work) { this.work = work; }
public IEnumerable<Customer> GetNewCustomersSince(DateTime time) {
work.On("CustomerDB", session =>
session.CreateCriteria<Customer>()
public class when_a_benchmark_has_more_than_3_percent_assets_more_than_5_percent_change_in_weight
{
Establish context = () =>
{
Input input;
given.input.for_account("XYZ123").called(out input)
.with_position().on(Clock.Today)
.with_an_asset_valued_at(10).cusip("1")
.with_an_asset_valued_at(90).cusip("2")
#-------------------------------------------------------------------------------
# Downloads photos from National Geographic's Photo Contest
#-------------------------------------------------------------------------------
param($res = '1280', $year = '2008')
$client = New-Object System.Net.WebClient
$client.Headers.Add('User-agent', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)')
$prefixes = @{
'2008' = @('1107', '1103', '1027', '1020', '1014', '1006', '0929', '0922',
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
namespace DbSlim
{
public class Insert
{
private string connectionString;
(*
Very ugly, very rough, very F# 101 <- my attempt to implement
STOMP [http://stomp.codehaus.org/Protocol].
This is the first time I've really tried using active patterns and
absolutely the first time I've used MailboxProcessors.
There are a couple of concepts I am still trying to work out:
1) What exactly happens with AsyncResponse's in mailboxes...I think I
// Adds the integers in a string like "1,2,3" = 6,
// or "//;\n1;2;3" = 6
public int Add(string value)
{
if (string.IsNullOrEmpty(value))
return 0;
var delimters = new char[] { ',', '\n' };
if (value.StartsWith("//"))
{
char[] GetDelimeters(string s)
{
if (s.StartsWith("//"))
return s.Substring(2, 1).ToCharArray();
else
return new char[] { ',', '\n' };
}
string GetValueToParse(string s)
{
char[] GetDelimeters(string s)
{
return HasCustomTokens(s) ?
s.Substring(2, 1).ToCharArray()
: new char[] { ',', '\n' };
}
string GetValueToParse(string s)
{
return HasCustomTokens(s) ?
let ex (p : bool) =
if p then ignore()
else failwith "gusto"
let f () : unit =
ex false
(* stack trace doesn't include f's body. why? *)
f()