Skip to content

Instantly share code, notes, and snippets.

David Vallner millimoose

Block or report user

Report or block millimoose

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View DictionaryFormatProvider.cs
class DictFormatProvider : IFormatProvider, ICustomFormatter
{
IDictionary<string, object> _values;
public DictFormatProvider(IDictionary<string, object> values) {
_values = values;
}
public object GetFormat(Type type) {
return type == typeof(ICustomFormatter) ? this : null;
}
View DungeonWorldAdvantage.cs
void Main()
{
var d6range = Enumerable.Range(1, 6);
var rolls = from d1a in d6range // first die of first roll
from d1b in d6range // second die of first roll
from d2a in d6range // first die of second roll
from d2b in d6range // second die of second roll
select new { d1a, d1b, d2a, d2b }; // all four dice rolled
var advantages = from r in rolls
View keybase.md

Keybase proof

I hereby claim:

  • I am millimoose on github.
  • I am millimoose (https://keybase.io/millimoose) on keybase.
  • I have a public key whose fingerprint is A1F5 EE99 0430 3765 703E A3F4 E888 75B3 78CD 990D

To claim this, I am signing this object:

View SetterFromGetter.cs
Expression<Action<TObject, TProperty>>
SetterFromGetter<TObject, TProperty>(Expression<Func<TObject, TProperty>> getter)
{
var objectParam = getter.Parameters.Single();
var valueParam = Expression.Parameter(getter.Body.Type);
return Expression.Lambda<Action<TObject, TProperty>>(
Expression.Block(
Expression.Assign(
getter.Body,
valueParam
@millimoose
millimoose / PropertyEqualityComparer.cs
Created Sep 25, 2013
The last equality comparer implementation you'll need
View PropertyEqualityComparer.cs
public class PropertyEqualityComparer<TItem> : EqualityComparer<TItem>
{
readonly Func<TItem, object> _getter;
public PropertyEqualityComparer(Func<TItem, object> getter)
{
_getter = getter;
}
public override bool Equals(TItem x, TItem y)
{
View Deploy.py
import os
from os import path
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException
CSS = By.CSS_SELECTOR
@millimoose
millimoose / oxout.y.c
Created May 7, 2013
Ox is a goddamn nightmare
View oxout.y.c
/* output from Ox version G1.04 */
%{
%}
%{
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <glib.h>
#include "ag.h"
View main.c
#define LOG_PV(func, sem, proc) \
printf("["#proc"] before "#func"("#sem") = %d\n", sem_getval(sem));\
func(sem);\
printf("["#proc"] after "#func"("#sem") = %d\n", sem_getval(sem));
#define LOG_P(sem, proc) \
LOG_PV(P, sem, proc)
#define LOG_V(sem, proc) \
LOG_PV(V, sem, proc)
@millimoose
millimoose / pointless.py
Created Oct 12, 2012
Python ridiculousness
View pointless.py
class meta_delegate(type):
def __call__(cls, *args, **kwargs):
return cls.__delegate(*args, **kwargs)
@staticmethod
def to(delegate):
def __new__(*args, **kwargs):
cls = meta_delegate(*args, **kwargs)
cls.__delegate = staticmethod(delegate)
return cls
You can’t perform that action at this time.