Skip to content

Instantly share code, notes, and snippets.

🌦️
Very slow to respond currently

Brendan Forster shiftkey

🌦️
Very slow to respond currently
View GitHub Profile
@shiftkey
shiftkey / gist:770803
Created Jan 8, 2011
Thought - Simpler XAML Markup
View gist:770803
# place to put click handlers
@Code Application.Views.MainView
# by default, textblocks use this style and do TextWrapping="Wrap"
@Default TextBlock Style="{DefaultFontStyle}" Wrap
# by default, Button uses this style
@Default Button Style="{DefaultButtonStyle}"
# tab indent represents child items
PhoneApplicationPage
Grid
@shiftkey
shiftkey / WP7 - Memory Profiling Hijinks
Created Feb 4, 2011
Investigating memory usage of a trivial Panorama-based WP7 application.
View WP7 - Memory Profiling Hijinks
// Scenario:
// Start with default WP7 Panorama application, two tabs each with listbox
// Added child page with panorama control, two tabs each with listbox
// Two ViewModels (Main and Child), each has a list of 270+ items
// No relationship between the ViewModels. Lazy-loaded data in-memory
Main - OnNavigatedTo - ApplicationCurrentMemoryUsage: 8036352
Main - OnNavigatedTo - ApplicationPeakMemoryUsage: 8048640
Main - Loaded - ApplicationCurrentMemoryUsage: 39870464
@shiftkey
shiftkey / Memory Usage for WP7 App
Created Feb 5, 2011
A longer running test for navigating between two screens of a WP7 app
View Memory Usage for WP7 App
Main - OnNavigatedTo - ApplicationCurrentMemoryUsage: 8036352
Main - OnNavigatedTo - ApplicationPeakMemoryUsage: 8048640
Main - Loaded - ApplicationCurrentMemoryUsage: 39862272
Main - Loaded - ApplicationPeakMemoryUsage: 39899136
Main - OnNavigatedFrom - ApplicationCurrentMemoryUsage: 51990528
Main - OnNavigatedFrom - ApplicationPeakMemoryUsage: 52760576
Child - OnNavigatedTo - ApplicationCurrentMemoryUsage: 51990528
View Generic Parameters in IronRuby
// here's the C# code we have to use
namespace Application
{
public class Factory
{
public T Get<T>(string parameter) where T : Proxy
{
return default(T);
}
@shiftkey
shiftkey / ObservableCollection Overloads
Created Apr 19, 2011
Comparing the behaviour between IEnumerable<T> and List<T>
View ObservableCollection Overloads
public ObservableCollection(IEnumerable<T> collection)
{
this._monitor = new SimpleMonitor<T>();
if (collection == null)
{
throw new ArgumentNullException("collection");
}
this.CopyFrom(collection);
}
@shiftkey
shiftkey / WAVEHDR
Created Jun 18, 2011
Example of a struct implemented as a class in C#
View WAVEHDR
// Example of a struct implementation for passing in information about a WAVE file
// http://msdn.microsoft.com/en-us/library/aa446573.aspx
/// <summary>
/// This structure defines the header used to identify a waveform-audio buffer.
/// typedef struct
/// {
/// LPSTR lpData;
/// DWORD dwBufferLength;
/// DWORD dwBytesRecorded;
@shiftkey
shiftkey / SessionService.cs
Created Jul 4, 2011
Faking a service call using Caliburn Micro Coroutines
View SessionService.cs
using System;
using System.ComponentModel.Composition;
using System.Windows.Threading;
using Caliburn.Micro;
namespace CaliburnMicroSample.Services
{
[Export(typeof(ISessionService))]
public class SessionService : ISessionService
{
@shiftkey
shiftkey / Program.cs
Created Aug 9, 2011
This is how you use TPL to crash your host process - don't ask me why you would use it in this way....
View Program.cs
static void Main(string[] args)
{
try
{
var factory = new TaskFactory();
var task = factory.StartNew(() => { throw new Exception(); });
task.Wait();
}
catch (Exception ex)
{
View gist:1161138
Visual Studio 2010 SP1
http://www.microsoft.com/download/en/details.aspx?id=23691
Fiddler
http://www.getfiddler.com/dl/Fiddler2BetaSetup.exe
Silverlight Spy
http://firstfloorsoftware.com/silverlightspy/download-silverlight-spy
Expression Blend
@shiftkey
shiftkey / gist:1178225
Created Aug 29, 2011
Enumerating Fun and Games in Ruby
View gist:1178225
# all i wanted to do was this with what I thought was
# an Enumerable set of posts using Jekyll
{% for ps in site.posts.skip(3) %}
<!-- partial view -->
{% endfor %}
# but i couldn't work out what type site.posts was at runtime
# ( using .class didn't output anything
# i stumbled (literally) across this alternate syntax which works
You can’t perform that action at this time.