Skip to content

Instantly share code, notes, and snippets.

View mrlacey's full-sized avatar
😇

Matt Lacey mrlacey

😇
View GitHub Profile
// CAREERS AT CONTOSO - TRIAL #2
// TITLE: Punch Card Puzzle
// AUTHOR: Vogel
// DESCRIPTION: Send screenshot of su ccessful output to @contosoishiring
<x:Code><![CDATA[private void mutYUUJ U7(object ksn8879, RoutedEventArgs khJJUh3){
System.Collections.Generic.Dictionary <int, Color>RX99RTOOUKL = new System.Collections.Generic.Diction
ary<int, Color>();
RX99RTOOUKL.Add(0, Color.FromRgb(0, 0 , 0));RX99RTOOUKL.Add(1, Color.FromRgb(255, 255, 255));
RX99RTOOUKL.Add(2, Color.FromRgb(224, 64, 64));RX99RTOOUKL.Add(3, Color.FromRgb(96, 255, 255));
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Text;
using System.Threading.Tasks;
using Windows.Web.Http;
using Windows.Web.Http.Headers;
using Newtonsoft.Json;
@mrlacey
mrlacey / addAppointment
Created March 9, 2015 13:45
Things you can do with Windows 10 Web Apps
addAppointment = function(e, t, n) {
if ("undefined" != typeof Windows) {
var o = new Windows.ApplicationModel.Appointments.Appointment;
o.allDay = !0, o.startTime = new Date(i(t, "dddd, Do MMM YYYY").format()), o.subject = "Trip to " + n, Windows.ApplicationModel.Appointments.AppointmentManager.showAddAppointmentAsync(o, {
x: 300,
y: 0,
width: 600,
height: 100
}).done(function(t) {
t ? (console.log("created!"), e()) : console.log("issue")
@mrlacey
mrlacey / MultiColorImageCreator
Created June 12, 2015 13:50
Snippet from a WPF app that produces an image where every pixel is a different color.
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows;
namespace GenerateMultiColorImages
{
public partial class MainWindow : Window
{
public MainWindow()
{
@mrlacey
mrlacey / AdMediatorSizeByDevice.xaml
Last active October 12, 2015 16:32
Example of how to change the size of the AdMediatorControl depending on the device width.
<Grid>
<Universal:AdMediatorControl x:Name="AdControl"
Id="ecba2d7a-f2d9-43bb-ab12-f8c5df300987"
Height="90"
Width="728" />
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="VisualStateGroup">
<VisualState x:Name="Mobile">
<VisualState.StateTriggers>
@mrlacey
mrlacey / CanPin-before
Last active December 14, 2015 22:48
On low spec WP8 devices we had an issue where the UI option to create a secondary tile wasn't always being enabled properly. After identifying the most likely cause as the `CanPin()` method I had to refactor it to make it debuggable and in doing so made the binding/timing issue go away (solved it).
internal bool CanPin()
{
return !this.IsPinned()
&& this.UnderlyingModel != null
&& !this.IsRunningInKidsCorner()
&& (this.UnderlyingModel.IsSpecial
|| string.IsNullOrWhiteSpace(this.UnderlyingModel.ArtUrl)
|| (!string.IsNullOrWhiteSpace(this.UnderlyingModel.ArtUrl)
&& this.imageCacher.IsCached(this.UnderlyingModel.ArtUrl)));
}
@mrlacey
mrlacey / CanPin-after
Last active December 15, 2015 05:29
On low spec WP8 devices we had an issue where the UI option to create a secondary tile wasn't always being enabled properly. After identifying the most likely cause as the `CanPin()` method I had to refactor it to make it debuggable and in doing so made the binding/timing issue go away (solved it).
internal bool CanPin()
{
if (this.IsPinned())
{
Debug.WriteLine("Cannot pin as already pinned");
return false;
}
if (this.UnderlyingModel == null)
{
@mrlacey
mrlacey / JsonSerializationComparison
Created August 20, 2013 11:24
A comparison of how to serialize and deserialize objects to and from JSON with both Json.Net and ServiceStack.Text
namespace JsonSerialization
{
using System;
class Program
{
static void Main(string[] args)
{
var firstObject = new MyClass { Something = "a value", Anotherthing = "another value" };
@mrlacey
mrlacey / CaretBrushResourceExample
Last active December 28, 2015 16:19
XAML that demonstrates issue with CaretBrush and shared resources
<phone:PhoneApplicationPage
x:Class="CaretBrushTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
SupportedOrientations="Portrait"
shell:SystemTray.IsVisible="True">
<phone:PhoneApplicationPage.Resources>
@mrlacey
mrlacey / gist:7779172
Created December 3, 2013 22:58
GlobeKeyReplacement
private static List<AlphaKeyGroup<PhoneContact>> CreateGroups(SortedLocaleGrouping slg)
{
var list = new List<AlphaKeyGroup<PhoneContact>>();
foreach (string key in slg.GroupDisplayNames)
{
var k = key;
if (key == "...")
{
k = "🌐"; // &#x1F310;