Skip to content

Instantly share code, notes, and snippets.

View mazur's full-sized avatar

Martin Mazur mazur

View GitHub Profile
@mazur
mazur / Underpants.cs
Created April 11, 2012 14:39
Steal Underpants Enumerator
namespace StealTheseUnderpants
{
using System;
public class Underpants
{
public UnderpantsEnumerator GetEnumerator()
{
return new UnderpantsEnumerator();
}
import java.util.HashMap
interface IOperator do
def run(x:int, y:int)
returns int
end
end
class Operators
macro def add_op(name, &op)
import java.util.HashMap
interface IOperator do
def run(x:int, y:int)
returns int
end
end
class Operators
def add
interface IOperator do
def run(x:int, y:int)
returns int
end
end
class Add
implements IOperator
def run(x:int, y:int)
@mazur
mazur / gist:1010987
Created June 6, 2011 20:09
IronRUby bug
"Find the 2345 number!"[/[0-9]+/] # => "5"
"Find the 2345 number!"[/[^0-9]+/] # => "Find the "
@mazur
mazur / gist:1003052
Created June 1, 2011 19:10
Build IronRuby on mono OSX/Ubuntu
#!/bin/bash
shopt -s extglob #Enables extglob
# OS: OSX 10.6.7 and Ubuntu 11.04
# Mono: 2.10.1
# Mono 2.10 is required since we need C# 4.0 support to compile IronRuby.
# C# 4.0 support can either be found in mono 2.10 or 2.6 compiled with special
# flags.
public IEnumerable<Action> Parameterized_shit_method_bithes()
{
yield return () => Run_me_with_params(5, 4);
yield return () => Run_me_with_params(7, 8);
yield return () => Run_me_with_params(12, 56);
}
protected void Run_me_with_params(int x, int y)
{
// Assert shit here
public class FooMap : ClassMap<Foo>
{
}
@mazur
mazur / gist:875813
Created March 18, 2011 09:23
For fun and fun
; This is a comment
; Everything that is declared "outside" a class is automatically placed in the class "Global"
this_is_a_variable: 5
; Types are not dynamic, they are inferenced.
this_is_a_method: (x, y) {
result: x + y; Everything after ; is not read and treated like a comment