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 / NonTopmostPopup.cs
Created April 5, 2011 08:04
WPF: Popup that is only topmost with respect to parent window. Taken from the comments at http://chriscavanagh.wordpress.com/2008/08/13/non-topmost-wpf-popup/ (Joe Gershgorin) which was in not easy to digest state
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Interop;
/// <summary>
/// Popup with code to not be the topmost control
@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 / HttpFileServer.cs
Created April 17, 2010 09:39
Smallest file web server
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Web;
public class HttpFileServer : IDisposable
{
private readonly string rootPath;
private const int bufferSize = 1024*512; //512KB