Skip to content

Instantly share code, notes, and snippets.

JamieMason /
Created Sep 14, 2018
Group Array of JavaScript Objects by Key or Property Value

Group Array of JavaScript Objects by Key or Property Value


const groupBy = key => array =>
  array.reduce((objectsByKeyValue, obj) => {
    const value = obj[key];
    objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
    return objectsByKeyValue;
kenegozi / XunitConsoleForwarder.cs
Created Jun 25, 2017
Capturing console output in Xunit 2 tests
View XunitConsoleForwarder.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Xunit.Abstractions;
namespace MagicalUnicorns {
public class XunitConsoleForwarder : TextWriter {
private readonly ITestOutputHelper output;
alexlau811 / ExtendedPageRenderer.cs
Created Feb 22, 2015
Move toolbar items with priority = 0 to LeftBarButtonItems on iOS with Xamarin Forms. Originally written by Murally at
View ExtendedPageRenderer.cs
[assembly: ExportRenderer(typeof(ContentPage), typeof(ExtendedPageRenderer))]
public class ExtendedPageRenderer : PageRenderer
public override void ViewWillAppear(bool animated)
var contentPage = this.Element as ContentPage;
if (contentPage == null || NavigationController == null)
micahlmartin / gist:4261551
Created Dec 11, 2012
Convert anonymous object to dictionary
View gist:4261551
public static IDictionary<string, object> ToDictionary(this object values)
var dict = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
if (values != null)
foreach (PropertyDescriptor propertyDescriptor in TypeDescriptor.GetProperties(values))
object obj = propertyDescriptor.GetValue(values);
dict.Add(propertyDescriptor.Name, obj);