Jacob Carpenter’s Weblog

October 22, 2014

ES6 Quicksort

Filed under: Uncategorized — Jacob @ 9:13 pm

Playing around with some ES6 features:

function quicksort([head, ...tail]) {
   if (head === undefined)
      return [];

   return [...quicksort([for (x of tail) if (x < head) x]),
      head,
      ...quicksort([for (x of tail) if (x >= head) x])];
}

Destructuring, rest, spread, comprehensions… I’m looking forward to writing more ES6.

March 12, 2009

Google Reader Tip

Filed under: Uncategorized — Jacob @ 12:10 pm

Sorry to break a long hiatus with such a lame, non-programming post. But, here’s a tip for Google Reader users:

A coworker of mine appears in my google talk list, but was not able to see my shared items in his Reader. We checked the settings a number of times, but to no avail.

Another coworker recommended the “try changing this, and then changing it back” strategy. I was skeptical, but reluctantly tried it…

And it worked!

So, if you use Google Reader and share items, check to make sure you’re sharing with everyone you intend to:

1. Click sharing settings on the left-hand side of Reader:

Reader-001

2. Click “Change” on the right-hand side of the newly displayed page:

Reader-002

3. Toggle the radio button to “Share with ‘Friends’” and click Save:

Reader-003

Repeat steps 2 and 3, but select “Share with all of my chat contacts,” the second time.

Hope this helps.

June 18, 2008

.Any overload

Filed under: Uncategorized — Jacob @ 4:12 pm

Nice:

if (folderPaths.Any(path => !Directory.Exists(path)))
    throw new DirectoryNotFoundException();

Nicer:

string pathNotFound;
if (folderPaths.Any(path => !Directory.Exists(path), out pathNotFound))
    throw new DirectoryNotFoundException("Could not find path: " + pathNotFound);

The implementation of

    public static bool Any<T>(this IEnumerable<T> source,
        Func<T, bool> predicate, out T found)

left as a trivial exercise to the reader.

June 16, 2008

Hello, world!

Filed under: Uncategorized — Jacob @ 9:12 am

Jonas Adam Carpenter

Jonas Adam Carpenter; born June 4th @ 6 lbs. 3 oz., 19 in.

(Sorry for the entirely non-technical post. I’ll be blogging more C# again, soon.)

January 28, 2008

Windows Live Writer Plugin: Element tag around

Filed under: Uncategorized — Jacob @ 10:01 pm

Over the weekend, I met Joe Cheng from the Windows Live Writer team. After asking him about the ease (or potential lack thereof) of plugin authoring, he walked me through a couple of scenarios.

It turns out authoring Live Writer plugins is as easy as using the app itself. Pretty remarkable considering the app is designed to be simple enough that my mom could use it (though I did have trouble locating some simple documentation to compellingly illustrate that fact). No offense, mom.

Joe’s demonstration culminated with showing off his powerful Dynamic Template plugin. He’s even shared the source at CodePlex.

However, not being content to use what’s available (and because it was so ridiculously easy), I decided to write my own plugin:

Element tag around

In the textual discussion of code-type stuff, I’m fond of marking up keywords / class names / local variables / etc. with the html code element. See, I just did it.

I wanted a plugin to simplify adding those elements. I wanted it to be fast to use [keyboard shortcuts]. Also, I know there are all these additional HTML computer code phrase elements, but it’s too inconvenient to remember what they are.

Enter Element tag around:

image

image

The most time consuming part of creating the plugin—which took a whopping lunch break—was the layout of the elements on the dialog. Coming from a WPF mindset, dynamically laying out elements in Windows Forms sucks.

As you can see from the screenshot, the available elements are all clearly listed and are insertable via keyboard shortcut (or by simply clicking the associated LinkLabel).

And yes, that was a gratuitous use of my new plugin.

Enjoy.

Blog at WordPress.com.