Skip to content

Instantly share code, notes, and snippets.

View jeffwilcox's full-sized avatar

Jeff Wilcox jeffwilcox

View GitHub Profile
@jeffwilcox
jeffwilcox / gist:2431507
Created April 20, 2012 20:12
Reflection comparison
// Windows Phone / Standard .NET:
// var mi = dataLoaderType.GetMethod(methodName, paramTypes);
// Windows 8 XAML Metro style app:
var mi = dataLoaderType.GetTypeInfo().GetDeclaredMethods(methodName);
MethodInfo actualMethod = null;
foreach (var method in mi)
{
// Eeeew code.
var parameters = method.GetParameters();
@jeffwilcox
jeffwilcox / gist:2432351
Created April 20, 2012 22:33
WinRT IsInstanceOfType, IsAssignableFrom
/// <summary>
/// Determines whether the specified object is an instance of the current Type.
/// </summary>
/// <param name="type">The type.</param>
/// <param name="o">The object to compare with the current type.</param>
/// <returns>true if the current Type is in the inheritance hierarchy of the
/// object represented by o, or if the current Type is an interface that o
/// supports. false if neither of these conditions is the case, or if o is
/// null, or if the current Type is an open generic type (that is,
@jeffwilcox
jeffwilcox / installMongoDB.sh
Last active December 18, 2015 08:09
Used for preparing a simple CentOS VM for MongoDB by adding the 10gen repo and installing the packages.
# Install MongoDB on CentOS
cat > ./10gen.repo << "YUM10GEN"
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0
enabled=1
YUM10GEN
@jeffwilcox
jeffwilcox / mit-copyright-header.js
Last active November 19, 2015 19:12
Copyright Header - MIT
@jeffwilcox
jeffwilcox / WittyBanter.cs
Created January 16, 2012 07:27
Just a fun way to show something different while things are loading.
//
// Copyright (c) 2010-2011 Jeff Wilcox
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
//
// Copyright (c) 2010-2011 Jeff Wilcox
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
@jeffwilcox
jeffwilcox / Generic.xaml
Created February 10, 2011 08:53
Simple stab at a base window class that doesn't use popup but depends on a frame
<Style TargetType="layoutToolkit:HeaderedContentControl">
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="VerticalContentAlignment" Value="Top"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="layoutToolkit:HeaderedContentControl">
<StackPanel>
<ContentPresenter
Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
@jeffwilcox
jeffwilcox / NegativeMarginHyperlinkButtonSample.xaml
Created December 8, 2010 07:37
A sample hyperlink button for Windows Phone where the negative margins allow for a larger touch target.
<Style
x:Key="AccentHyperlink"
TargetType="HyperlinkButton">
<Setter Property="Foreground" Value="{StaticResource PhoneAccentBrush}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMedium}" />
<Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiBold}" />
<Setter Property="Padding" Value="0" />
<Setter Property="Template">
<Setter.Value>