Skip to content

Instantly share code, notes, and snippets.

View martindemello's full-sized avatar

Martin DeMello martindemello

View GitHub Profile
// WTF: Is there really no Gdk.RGBA constructor? No docs either!
let mutable color = Gdk.RGBA ()
color.Red <- 1.0
color.Green <- 1.0
color.Blue <- 0.8
color.Alpha <- 1.0
current.OverrideBackgroundColor(StateFlags.Normal, color)
@martindemello
martindemello / chess.scm
Last active October 14, 2015 07:49
iup cells example
(use iup)
(define (nlines self) 8)
(define (ncols self) 8)
(define (height self line) 50)
(define (width self col) 50)
(define (draw self i j xmin xmax ymin ymax canvas) 'default)
(define dlg
@martindemello
martindemello / chain-of-responsibility.rb
Created February 20, 2015 21:30
chain of responsibility example in ruby
class PurchaseApprover
# Implements the chain of responsibility pattern. Does not know anything
# about the approval process, merely whether the current handler can approve
# the request, or must pass it to a successor.
attr_reader :successor
def initialize successor
@successor = successor
end
@martindemello
martindemello / gist:5894430
Created June 30, 2013 08:54
simple reactive crossword grid experiment. dead slow for some reason.
import Dict
import Keyboard
import Char
side = 30
n = 15
x0 = side * n
-- model
@martindemello
martindemello / gist:5790922
Created June 16, 2013 05:50
simple crossword grid in eml
import Dict
side = 30
n = 15
x0 = side * n
-- coordinates
toScreen (x, y) = (side * x - x0, side * (n - y))
fromScreen (x, y) = (div (x + x0) side, n - div y side)
@martindemello
martindemello / stringtemplate.d
Created May 13, 2012 07:17
string templating in D
// first version - code demonstrating the basic idea.
// see below for a fuller-featured implementation
import std.string;
import std.range;
import std.stdio;
/* A very simple string templating system. Placeholders of the form
* %{variable} are replaced by the corresponding variable in the current
* scope.