Skip to content

Instantly share code, notes, and snippets.

@flq
flq / HelpController.cs
Created May 6, 2011 13:28
Current Fubu registry
using FubuMVC.Core;
namespace CharmSim.Controllers
{
public class HelpController
{
public HelpViewModel Start()
{
return new HelpViewModel { Title = "Hello from Controller! " };
}
@flq
flq / RelayCommand
Created February 18, 2011 11:17
A command that runs on delegates and implements WPF ICommand
using System;
using System.Windows.Input;
namespace Something
{
public class RelayCommand : ICommand
{
private readonly Func<object, bool> _canExecute;
private readonly Action<object> _execute;
@flq
flq / A copy op preserving relative folder structure
Created August 10, 2010 07:06
pieces regarding powershell usage
$a = pwd
ls -r |
? { !$_.name.Contains(".g.") } |
? { $_.Extension -eq ".cs" -or $_.Extension -eq ".csproj" } |
? { $_.lastwritetime -gt [DateTime]::Now.AddHours(-6) } |
% {
$relative = $_.fullname.Replace($a.Path + "\","")
$Path = [System.IO.Path]::GetDirectoryName($relative)
mkdir c:\temp\$path -erroraction SilentlyContinue
Copy-Item -path $relative -destination c:\temp\$path
@flq
flq / Permutation.hs
Last active August 29, 2015 14:23
No-frills permutation code in Haskell
module Permutation where
permutate :: [a] -> [[a]]
permutate [x1,x2] = [[x1,x2],[x2,x1]]
permutate items = concat $ map p $ getEachInFrontOnce items
where
p (x:xs) = map (\items -> [x]++items) $ permutate xs
getEachInFrontOnce items = map (putItemAtIndexToFront items) [0..length items-1]
putItemAtIndexToFront items idx = [items!!idx] ++ take idx items ++ drop (idx+1) items
@flq
flq / ast.fs
Last active August 29, 2015 14:07
Lexing and Parsing in F# on Cobol
module Ast
open System
type slotDeclaration= {
Index : int
Name : string
Size : int
}