Skip to content

Instantly share code, notes, and snippets.

View jaredpar's full-sized avatar

Jared Parsons jaredpar

View GitHub Profile
/// <summary>
/// This will get the text of the ITextView line as it appears in the actual user editable
/// document.
/// </summary>
public static bool TryGetText(ITextView textView, ITextViewLine textViewLine, out string text)
{
var extent = textViewLine.Extent;
var bufferGraph = textView.BufferGraph;
try
{
/// <summary>
/// This will get the text of the ITextView line as it appears in the actual user editable
/// document.
/// </summary>
public static bool TryGetText(ITextView textView, ITextViewLine textViewLine, out string text)
{
var extent = textViewLine.Extent;
var bufferGraph = textView.BufferGraph;
try
{
@jaredpar
jaredpar / gist:5163187
Last active December 14, 2015 23:09
Fun with booleans
class Program
{
[StructLayout(LayoutKind.Explicit)]
struct Union
{
[FieldOffset(0)]
internal byte ByteField;
[FieldOffset(0)]
internal bool BoolField;
@jaredpar
jaredpar / gist:5521756
Created May 5, 2013 18:49
When C# makes you wish you were using F#
C#
private static readonly ReadOnlyCollection<ITagSpan<IntraTextAdornmentTag>> EmptyTagColllection = new ReadOnlyCollection<ITagSpan<IntraTextAdornmentTag>>(new List<ITagSpan<IntraTextAdornmentTag>>());
F#
let emptyTagCollection = List.empty
@jaredpar
jaredpar / gist:5744216
Created June 9, 2013 16:43
jaredpar vimrc file
set nobackup
set nocp
set tabstop=4
set shiftwidth=4
set et
set ignorecase
set hlsearch
set ai
set ruler
package com.koushikdutta.async;
import java.io.IOException;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.util.Set;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
/**
function f1() { return @("hello"); }
function f2() { return @("hello", "world"); }
$a = f1;
write-host $a.Length # prints 5
$a = f2;
write-host $a.Length # prints 2
@jaredpar
jaredpar / keybase.md
Created April 29, 2014 04:21
keybase.md

Keybase proof

I hereby claim:

  • I am jaredpar on github.
  • I am jaredpar (https://keybase.io/jaredpar) on keybase.
  • I have a public key whose fingerprint is 45AE AD6B 43A8 170C FF01 A26F 95C7 749A D1E7 9177

To claim this, I am signing this object:

class Other
{
internal static Other Instance
{
get { return null; }
}
internal int Compare(A left, A right) { return 0; }
static internal int Compare(B left, B right) { return 0; }
}
static void Main(string[] args)
{
A a = default(A);
D d = new D();
d.Foo(a); // Prints D.Foo
}
struct A { }
struct B
{