Skip to content

Instantly share code, notes, and snippets.

View shiftkey's full-sized avatar
🌴
Not checking notifications, for realsies

Brendan Forster shiftkey

🌴
Not checking notifications, for realsies
View GitHub Profile
@shiftkey
shiftkey / main.cs
Last active December 16, 2015 16:39
LINQ-splaining
public static void Main() {
var found = elements.Where(e => e == "foo");
// could be described as:
// - found is elements where e equals foo
// - found equals elements where e equals foo
var match = elements.FirstOrDefault(e => e > 0);
// could be described as:
// - match equals elements first or default where e is greater than 0
@shiftkey
shiftkey / Snippet.cs
Created March 27, 2013 08:55
Set a proxy on HttpClient
var proxy = new WebProxy {Address = new Uri("http://someurl/")};
var handler = new WebRequestHandler {Proxy = proxy};
var client = new HttpClient(handler);
client.SendAsync(new HttpRequestMessage(HttpMethod.Get, "http://otherurl/"));
@shiftkey
shiftkey / Program.cs
Last active December 15, 2015 09:09
Test Harness for a regex that is giving me hell right now
using System;
using System.Text.RegularExpressions;
namespace RegexTester
{
class Program
{
private static void Main(string[] args)
{
var allText = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<doc>\r\n<!-- code start foo csharp -->\r\n<foo />\r\n<bar />\r\n<!-- end code foo -->\r\n<baz />\r\n</doc>";
@shiftkey
shiftkey / nancy.csx
Last active December 15, 2015 00:19
Investigating a scriptcs issue with the latest dev build (SHA 3325398)
D:\Code\github\scriptcs\scriptcs-samples\nancy [master +1 ~0 -0 !]> scriptcs sta
rt.csx
Found assembly reference: D:\Code\github\scriptcs\scriptcs-samples\nancy\package
s\Nancy.0.16.1\lib\net40\Nancy.dll
Found assembly reference: D:\Code\github\scriptcs\scriptcs-samples\nancy\package
s\Nancy.Hosting.Self.0.16.1\lib\net40\Nancy.Hosting.Self.dll
Found assembly reference: D:\Code\github\scriptcs\scriptcs-samples\nancy\package
s\Nancy.Bootstrappers.Autofac.0.16.1\lib\net40\Nancy.Bootstrappers.Autofac.dll
Found assembly reference: D:\Code\github\scriptcs\scriptcs-samples\nancy\package
s\Autofac.2.6.3.862\lib\NET40\Autofac.Configuration.dll
@shiftkey
shiftkey / duchess.md
Last active December 14, 2015 01:38
Some words about a project idea codenamed Duchess - the goal is to make a replacement for Sandcastle and make creating documentation for open source project cool again

Burn Sandcastle to the Ground

Addressing The Documentation Problem

I've had lots of discussions with people over the past few days around how open source projects in the .NET space have poor documentation (if it exists). So how do we fix this?

At a high-level, I've got these goals in mind:

  • make it easy
  • make it cool
@shiftkey
shiftkey / test.ps1
Created February 10, 2013 09:41
Sorting code files by line count using Powershell (because I want to tackle the simplest ones first)
$sortedFiles = @()
$files = Get-ChildItem D:\Code\github\shiftkey\UbiqRT-Storage\Storage\ -Filter *.cs -Recurse
ForEach($file in $files) {
$count = (Get-Content $file.FullName | Measure-Object).Count
if ($count -gt 0) {
$fullName =
$obj = New-Object System.Object
@shiftkey
shiftkey / talks.md
Last active December 12, 2015 06:19
Sketching out some ideas for NDC talk submissions. Feel free to leave a comment.

Hacking on Portable Class Libraries For Fun and Profit

Do you do cross-platform development on .NET? Are you sick of #ifdef hell or maintaining duplicate codebases which do essentially the same thing? Let me show you Portable Class Libraries. They're neat.

Things to cover:

  • why on earth should i care?
@shiftkey
shiftkey / app.py
Last active December 12, 2015 03:19
A bit rusty but here's a script to parse a collection of KML files and pull out all the interesting data
from xml.dom.minidom import parse
def get_label(node):
name = node.getElementsByTagName('name')[0]
label = name.firstChild.nodeValue
return label
def get_coords(node):
coordinates = node.getElementsByTagName('coordinates')[0]
coords = coordinates.firstChild.nodeValue
@shiftkey
shiftkey / MainWindow.cs
Last active December 12, 2015 01:08
Musing on supplying sample data in a non-sucky way (with ReactiveUI)
using ReactiveUI;
namespace WpfApplication1
{
public class DesignMainViewModel : MainViewModel
{
public DesignMainViewModel()
{
UserName = "shiftkey";
}
@shiftkey
shiftkey / gist:4661947
Last active December 11, 2015 21:19
Formatting strings - looks to be same between XAML and regular .NET code
using System.Windows;
using System.Windows.Data;
using Xunit;
namespace ConsoleApplication2
{
public class Test
{
DependencyObject dObj = new DependencyObject();