Type–Hover–Swipe in 96 Bytes: A Motion Sensing Mechanical Keyboard

microsoft research (2)

Microsoft Research paper: http://research.microsoft.com/en-us/projects/typehoverswipe/


Binary Birthdays

Life is way simpler when you only have to deal with two numbers instead of 10: only zeros and ones. Applied to birthdays it creates way more opportunities to celebrate. Use the one and only Binary Birthday Calculator (commonly known as the BBC) and create a unique binary present, print it out and wear it proudly on www.binarybirthdays.com

C# Expression Trees

Just a quick example that you can try yourself. It can be hard to write and debug Expression Trees but they are very powerful.

using System;
using System.Linq.Expressions;

namespace ConsoleApplication2
class Program
static void Main(string[] args)
Func<int, int> f = (x) => x + 1; // Same as: x++
var result = f(1);
Console.WriteLine("My result: " + result);

// ------

var result2 = f.Invoke(1);
Console.WriteLine("My result (via Invoke): " + result2);

// ------

ParameterExpression param0 = Expression.Parameter(typeof(int)); // first parameter
ParameterExpression param1 = Expression.Parameter(typeof(int)); // second parameter
ConstantExpression const0 = Expression.Constant(1);             // a constant

BinaryExpression expr = Expression.Add(Expression.Subtract(param1, const0), param0); // Same as: param1 - constant + param0
Expression<Func<int, int, int>> lambdaExpr = Expression.Lambda<Func<int, int, int>>(expr, param0, param1); // creates the lambda delegate

Func<int, int, int> compiledExpr = lambdaExpr.Compile(); // compiles the expression tree
var result3 = compiledExpr(1, 1); // executes the epxression tree with param0 and param1

Console.WriteLine("My result via Expression: " + result3);

// Don't close the console directly

See also the ExpandoObject in C#.

Enjoy 😉