Skip to content

Instantly share code, notes, and snippets.

Martin DeMello martindemello

Block or report user

Report or block martindemello

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 gist:99a984958e33dae389f4fc7898aa9fb8
// 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 Oct 14, 2015
iup cells example
View chess.scm
(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 Feb 20, 2015
chain of responsibility example in ruby
View chain-of-responsibility.rb
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 Jun 30, 2013
simple reactive crossword grid experiment. dead slow for some reason.
View gist:5894430
import Dict
import Keyboard
import Char
side = 30
n = 15
x0 = side * n
-- model
@martindemello
martindemello / gist:5790922
Created Jun 16, 2013
simple crossword grid in eml
View gist:5790922
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
string templating in D
View stringtemplate.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.
You can’t perform that action at this time.