Skip to content

Instantly share code, notes, and snippets.

"1,2,1,1,0,3,1,0,0,2,4,1,0,0,0,0,2,1,0,3,1,0,0,0,6,1,3,0,0,0"
.Split(',')
.Select(x => x[0] == '0' ? '1' : ' ')
.Aggregate("", (x, y) => x += y)
.Split(' ')
.Max(x => x.Length)
@orangutanboy
orangutanboy / TableExtensions.cs.
Created October 25, 2013 20:59
This is an implementation of a disposable HtmlHelper extension
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Web.Mvc;
namespace Demo.Helpers
{
public static class TableExtensions
{
foreach (var s in Enumerable.Range(1, 11).Zip("Davis, Clyne, Fonte, Hooiveld, Shaw, Davis, Schneiderlin, Cork, Lallana, Rodriguez, Lambert".Split(new[] { ", " }, StringSplitOptions.None), (num, name) => num + ". " + name))
{
Console.WriteLine(s);
}
@orangutanboy
orangutanboy / GestureEnabledDisplay_T35
Created May 19, 2013 09:44
This is a subclass of Display_T35 that allows a LongTouch gesture
public class GestureEnabledDisplay_T35 : Gadgeteer.Modules.GHIElectronics.Display_T35
{
private long _touchdownTicks;
private const long NanosecondsInMilliseconds = 10000;
public delegate void LongTouchEventHandler(object sender, EventArgs args);
public event LongTouchEventHandler LongTouch;
/// <summary>
/// The number of milliseconds a touch needs before it raises a longtouch event
/// <reference path="scripts/jquery.d.ts" />
module Trainline {
export var pointState = {
Available: "AVAILABLE",
Crossed: "CROSSED",
Unavailable: "UNAVAILABLE"
}
export var pointSide = {
@orangutanboy
orangutanboy / BishopsMoves.linq
Last active October 31, 2015 21:30
Answers to Mark Heath's Lunchtime Linq Challenge 2
var startX = 'C';
var startY = 5;
var diagonals = Enumerable.Range(65, 8)
.SelectMany(x => Enumerable.Range(1, 8), (x, y) => new { x = (char)x, y })
.Where(coord =>
((coord.x - startX == coord.y - startY))
|| (startX - coord.x == coord.y - startY)
|| (startX - coord.x == coord.y + startY)
|| (coord.x - startX == coord.y + startY))
@orangutanboy
orangutanboy / WeakRef.cs
Created November 30, 2012 20:39
WeakReference v WeakReference<T>
using System;
using System.Diagnostics;
using System.Xml;
namespace WeakReferenceDemo
{
class Program
{
static void Main(string[] args)
{
@orangutanboy
orangutanboy / DemoHub.cs
Created November 24, 2012 21:15
SignalR Demo
using Microsoft.AspNet.SignalR.Hubs;
using System.Timers;
namespace SignalRDemo
{
public class DemoHub : Hub
{
private readonly DemoTimer _demoTimer;
public DemoHub()
@orangutanboy
orangutanboy / callerinformation.cs
Created October 10, 2012 19:14
Caller information attributes demo
using System;
using System.IO;
using System.Runtime.CompilerServices;
class CallerInfoDemo
{
static void Main(string[] args)
{
LogMe();
Method1();
@orangutanboy
orangutanboy / Explicit_and_override.cs
Created September 19, 2012 20:51
ToString interface overrides
using System;
namespace Demo
{
class Program
{
static void Main(string[] args)
{
var myClass = new MyClass();