View Command.cs
public interface ICommand
{
}
View ElementScopeExtensions.cs
public static bool HasValue(this ElementScope scope, string text, Options options = null)
{
var f = scope.GetType().GetField("options", BindingFlags.Instance | BindingFlags.NonPublic);
var config = (Options)f.GetValue(scope);
var robustly = new RetryUntilTimeoutRobustWrapper();
return robustly.Robustly(new HasValueQuery(scope, text, options ?? config));
}
class HasValueQuery : Query<bool>
{
View task.cs
public class Task : ActiveRecord
{
public string Name { get; set; }
public int AssignedTo_UserId { get; set; }
public DateTime DueOn { get; set; }
public Task()
{
DueOn = DateTime.Now.AddDays(1);
}
View nuget-restore.ps1
$packageConfigs = dir -r -include packages.config -exclude **\.hg\** | %{ $_.FullName }
$packageConfigs | %{ nuget.exe install $_ }
View canopy-dynamic-load-contexts.fs
// ContextAttribute.fs
module ContextAttribute
type ContextAttribute() =
inherit System.Attribute()
// example_test_file.fs
module example_test_file
open canopy
View word-ladder.fsx
let words = System.IO.File.ReadAllLines("four-char-dictionary.txt")
let isWordInDict word =
words |> Seq.exists (fun w -> w = word)
let filterToDict words =
words |> List.filter isWordInDict
let filterNotSeen (seen : Set<string>) words =
words |> List.filter (fun w -> not(seen.Contains(w)))
View find-connected-graphs.fsx
type 'a Node = 'a * 'a list
type 'a Graph = 'a Node list
let g = [('a', ['b'; 'd']); ('b', ['a'; 'c'; 'd']); ('c', ['b']); ('d', ['a'; 'b']); ('e', ['f']); ('f', ['e'])]
let findConnectedGraph (map : Map<'a, 'a list>) (firstVal : 'a) =
let rec walk (seen : 'a list) (tosearch : 'a list) =
let isSeen n =
seen |> List.exists (fun i -> i=n)
let notSeenOnly (nodes : 'a list) =
nodes |> List.filter (fun i -> not <| isSeen i)
View gist:2660500
@{var anEmptyRegex = "";}
<script type="text/javascript">
var r = /@anEmptyRegex/i;
callSomeFunction(r);
</script>
-- Razor Output --
<script type="text/javascript">
View 1-Simplest.cs
public class SpeakerController : Controller
{
public ActionResult Create(int presentationId, FormCollection data)
{
var presentation = Presentation.Find(presentationId);
var vm = SpeakerNewViewModel.Build(presentation);
UpdateModel(vm, data);
var presentationApi = new PresentationApi(presentationId);
View gist:1348711
$len = (ls -r -filter *.cs | %{ hg blame -u $_.FullName } | ?{ $_ -match '^\s*claco' }).Length; "claco wrote $len lines of code"