Skip to content

Instantly share code, notes, and snippets.

View jrwren's full-sized avatar
๐Ÿ’ญ
๐Ÿคฏ๐Ÿ’ฏ๐Ÿ‘๐Ÿ”ฅ๐ŸŽ‰๐Ÿคทโ€โ™€๏ธ๐Ÿ˜๐Ÿ˜•๐Ÿ•ด๐Ÿฝ๐Ÿ˜ต๐Ÿ˜ž๐Ÿค•๐Ÿคฎ

Jay R. Wren jrwren

๐Ÿ’ญ
๐Ÿคฏ๐Ÿ’ฏ๐Ÿ‘๐Ÿ”ฅ๐ŸŽ‰๐Ÿคทโ€โ™€๏ธ๐Ÿ˜๐Ÿ˜•๐Ÿ•ด๐Ÿฝ๐Ÿ˜ต๐Ÿ˜ž๐Ÿค•๐Ÿคฎ
View GitHub Profile
@jrwren
jrwren / gist:1174270
Created August 26, 2011 19:52
conditional global exception handling
if (!System.Diagnostics.Debugger.IsAttached)
{
this.DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);
AppDomain.CurrentDomain.UnhandledException += this.CurrentDomain_UnhandledException;
}
@jrwren
jrwren / gist:1182046
Created August 30, 2011 21:06
why does this regex result in two matches?
public virtual string[] _ParseCsvFormat(string value)
{
//var regexstr = @"(?:(?:""(?<m>[^""]*?,[^""]*?)""|(?<m>[^,]*)))(?:,|$)";
var regexstr = @"
(?:
(?:
""
(?<m>[^""]*?,[^""]*?)
""
|
@jrwren
jrwren / gist:1186660
Created September 1, 2011 17:07
immutable struct?
[DebuggerDisplay("\\{ Name = {Name}, Age = {Age} \\}")]
private sealed struct X : IEquatable<X>
{
private readonly string name;
private readonly int age;
public X(string name, int age)
{
this.name = name;
this.age = age;
@jrwren
jrwren / gist:1195187
Created September 5, 2011 15:04
settings:ApplicationSettingsBase
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.Settings
Designer.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.Applicati
onSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
@jrwren
jrwren / gist:1200833
Created September 7, 2011 15:12
ilist swap and move works on arrays
public static class ListExt //for List<> and IList<>
{
public static IList<T> Swap<T>(this IList<T> source, int oldIndex, int newIndex)
{
var temp = source[oldIndex];
source[oldIndex] = source[newIndex];
source[newIndex] = temp;
return source;
}
@jrwren
jrwren / gist:1339932
Created November 4, 2011 17:29
ienumerable tree traversal
/// <summary>
/// breadth first traversal
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="root"></param>
/// <param name="childrenSelector"></param>
/// <returns></returns>
public static IEnumerable<T> Traverse<T>(this T root, Func<T,IEnumerable<T>> childrenSelector)
{
yield return root;
On 11/11/2011 8:05 AM, vince wrote:
> On Fri, 11 Nov 2011 07:09:23 -0500, Bill_MI <bill@mi.no.spam.ath.cx>
> wrote:
>
>> An interesting read from opposing sides:
>>
>> https://bugs.launchpad.net/unity/+bug/882274
>>
>> This is NOT to start a discussion thread but to make people aware.
>> All political comments will be ignored.
@jrwren
jrwren / gist:1418972
Created December 1, 2011 18:55
ThingsThatAreNotAGoodIdeaThatIDoAnyway - ignore exceptions
public static class ThingsThatAreNotAGoodIdeaThatIDoAnyway
{
public static void IgnoreExceptions(this System.Threading.Tasks.Task task)
{
task.ContinueWith(t => t.Exception.Handle(e => true), System.Threading.Tasks.TaskContinuationOptions.OnlyOnFaulted);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
@jrwren
jrwren / gist:1502011
Created December 20, 2011 15:46
iOS resources
http://mobile.tutsplus.com/tutorials/iphone/ios-5-sdk-storyboards/