Skip to content

Instantly share code, notes, and snippets.

View follesoe's full-sized avatar
📱

Jonas Follesø follesoe

📱
View GitHub Profile
@follesoe
follesoe / TrackingViewModelTest.cs
Created April 28, 2012 18:08
Example code for blog post on testable WP7 apps.
namespace TestableGeoTrackerDemo.Test.ViewModel
{
[TestClass]
public class TrackingViewModelTest : SilverlightTest
{
private MockCompass _compass;
private MockGeoCoordinateWatcher _geoWatcher;
private TrackingViewModel _viewModel;
[TestInitialize]
@follesoe
follesoe / Pusher.cs
Created April 11, 2012 12:02
Class used to open push notification channel on Wordfeud WP7
// Maintains push notification channel
public class Pusher : IManagePushNotification
{
public event EventHandler<PusherUriEventArgs> ChannelUriUpdated;
private const string ChannelName = "WordfeudChannel";
private HttpNotificationChannel _pushChannel;
private bool _enabled;
public void Enable()
public byte[] Get()
{
byte[] data = null;
var manualResetEvent = new ManualResetEvent(false);
var timedOut = false;
var req = CreateGetHttpWebRequest(Url);
try
{
if (Config.Debug)
LogRequest(req, null);
class Program
{
static void Main(string[] args)
{
var handlers = new MyHandlerList();
handlers.Add(new ConcreteHandler());
var myHandler = handlers.Get<Message>();
}
private class MyHandlerList
@follesoe
follesoe / KeydownSearch.cs
Created February 10, 2012 10:12
Showing how to do as-you-type search in WP7
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Windows;
using Posten.Pakkesporing.Lib.Model;
using Posten.Pakkesporing.Lib.Services;
namespace Posten.Pakkesporing.Lib.ViewModels
@follesoe
follesoe / bowling.js
Created December 6, 2011 17:09
How far we got on bowling kata in JS with Buster
var buster = require("buster");
function Bowling() {
this.pins = [];
this.points = 0;
}
Bowling.prototype.roll = function (pins) {
this.pins.push(pins);
};
Bowling.prototype.isSpare = function (i) {
@follesoe
follesoe / Bug.xml
Created September 12, 2011 19:46
Exception from marketplace
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><s:Fault><faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</faultcode><faultstring xml:lang="en-US">Object reference not set to an instance of an object.</faultstring><detail><ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><HelpLink i:nil="true"/><InnerException i:nil="true"/><Message>Object reference not set to an instance of an object.</Message><StackTrace> at Microsoft.Wps.DevX.DevPortal.Services.ApplicationSubmissionService.RetrieveAccountId() in d:\bt\6528\private\DevX\DevPortal\Source\Services\ApplicationSubmissionService.cs:line 994&#xD;
at Microsoft.Wps.DevX.DevPortal.Services.ApplicationSubmissionService.GetCompanyCertificates() in d:\bt\6528\private\DevX\DevPortal\Source\Services\ApplicationSubmissionService.cs:line 686&#xD;
at SyncInvokeGetCompanyCertificat
System.ArgumentOutOfRangeException was unhandled
Message=Specified argument was out of the range of valid values.
Parameter name: childIndex
StackTrace:
at System.Windows.Media.VisualTreeHelper.GetChild(DependencyObject reference, Int32 childIndex)
at AvinorFlights.FlightsPage.<>c__DisplayClass7.<PopulateResult>b__3()
at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at System.Delegate.DynamicInvokeOne(Object[] args)
@follesoe
follesoe / ItemsControlVisibilityHelper.cs
Created August 17, 2011 18:01
ItemsControlVisibilityHelper
public class ItemsControlVisibilityHelper : ContentControl
{
public static readonly DependencyProperty ItemsControlProperty =
DependencyProperty.Register("ItemsControl",
typeof (ItemsControl),
typeof (ItemsControlVisibilityHelper),
new PropertyMetadata(default(ItemsControl), OnItemsControlChanged));
public ItemsControl ItemsControl
{
@follesoe
follesoe / PhotoCameraLuminanceSource.cs
Created July 22, 2011 01:29
PhotoCameraLuminanceSource
public class PhotoCameraLuminanceSource : LuminanceSource
{
public byte[] PreviewBufferY { get; private set; }
public PhotoCameraLuminanceSource(int width, int height) : base(width, height)
{
PreviewBufferY = new byte[width * height];
}
public override sbyte[] Matrix