Skip to content

Instantly share code, notes, and snippets.

@JoeRobich
JoeRobich / Settings.vb
Created August 11, 2011 20:38
The Visual Studio macros for creating a Settings menu/toolbar.
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics
Public Module Settings
Private Const FONT_SIZE_CATEGORY As String = "FontsAndColors"
@JoeRobich
JoeRobich / GeometryConverter.cs
Created April 7, 2012 18:43
Abstraction to allow System.Web.Extension JavaScriptConveters to run as JSON.Net JsonConverters.
using System;
using System.Collections.Generic;
using Serialization.Text
namespace Drawing.Geometry
{
public class GeometryConverter : IJsonConverter
{
public object Deserialize(IDictionary<string, object> dictionary, Type type, IJsonSerializer serializer)
{
@JoeRobich
JoeRobich / HashMap.as
Created September 14, 2012 04:26
ActionScript IoC
package com.thedevstop.utilities
{
import flash.utils.Dictionary;
public class HashMap extends Dictionary
{
public function get(key:*):*
{
return this[key];
}
@JoeRobich
JoeRobich / JsFactory.ts
Created October 7, 2012 05:01
Port of AsFac ( https://github.com/thedevstop/asfac ) to TypeScript. Greatly simplified since there is no reflection in TypeScript. Passes no parameters when invoking a constructor and does not perform property injection.
interface ICallback {
(factory:JsFactory, scopeName:string):any;
}
interface ICallbackDictionary {
[name:string]:ICallback;
}
class JsFactory {
static DefaultScopeName = '';
@JoeRobich
JoeRobich / KeyValueStore.cs
Created January 15, 2013 22:21
Simple KeyValueStore that I wrote and was unable to use.
public interface IKeyValueStore
{
object this[string key] { get; set; }
}
public static class KeyValueStoreExtensions
{
public static DateTime GetDateTime(this IKeyValueStore store, string key)
{
var val = store[key];
@JoeRobich
JoeRobich / ProcessRunner.cs
Created January 27, 2013 19:32
Quick stab at an architecture for running processes over data.
public interface IRunProcesses<T>
{
void RegisterProcess(IProcessItems<T> process);
}
public interface IProcessItems<T>
{
void Process(IEnumerable<T> items);
}
@JoeRobich
JoeRobich / Program.cs
Created February 4, 2013 22:40
Developer interview problem
void Main()
{
var unsortedNames = GetNames();
var sortedNames = SortNames(unsortedNames);
PrintArray(sortedNames);
}
// Formats and sorts an array of name strings.
// Input: An unordered array of strings in the format '{LastName}, {FirstName}'
// Output: An ordered array of strings in the format '{FirstName} {LastName}'
@JoeRobich
JoeRobich / json.pegjs
Created April 5, 2013 20:12
Simple incomplete JSON parser written in pegjs
{
function createObject(kvps) {
var object = {};
for (var index = 0; index < kvps.length; index++) {
var value = kvps[index].value;
value = value == undefined ? null : value;
object[kvps[index].key] = value;
}
return object;
}
@JoeRobich
JoeRobich / ConfidenceStore.cs
Last active December 16, 2015 07:38
Helpful utility for tracking which item in a group occurs at high enough of a frequency to call the confident item.
public class ConfidenceStore<T> where T : class
{
public event EventHandler<EventArgs<T>> Changed;
private Queue<T> queue;
private int length;
private int threshold;
private T confidentItem;
public ConfidenceStore(int length, int threshold)
@JoeRobich
JoeRobich / Program.cs
Created July 11, 2013 20:32
Use Linq expressions to test for `null`s in chained member access. For instance `ValidateNotNull(() => person.Address.State);` would return false if `person`, `person.Address`, or `person.Address.State` were `null`.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace TestNullCheckingExpressions
{
class Program