Skip to content

Instantly share code, notes, and snippets.

View MrSmith33's full-sized avatar

Andrey Penechko MrSmith33

View GitHub Profile
@MrSmith33
MrSmith33 / determinant.d
Created January 31, 2014 13:59
determinant.d
import rational;
import std.conv : to;
import std.algorithm;
import std.stdio;
import std.traits;
import matrix;
import vector;
ElementType pow(ElementType, I)(ElementType number, I power) if (isIntegral!I)
application {
window width=1280 height=800 caption="Example project" layout="docking" {
widget dock="fill" layout="absolute" {
-- This 'caption' property will be assigned to 'text' property of frame.header.caption widget as stated in frame template.
-- Also layout will not affect frame widget itself. It will be applied to frame.contentArea, because
-- later is marked as 'children-container' inside frame template.
frame pos="0 0" caption="Test frame. Uses template!" layout="docking" {
text-button dock="top" text="Click me"
line-edit dock="top" text="Edit me"
text-check dock="top" text="check me" check-group=0
@MrSmith33
MrSmith33 / gist:9374082
Created March 5, 2014 18:58
one-to-one binding
abstract class IProperty
{
// called when value changes.
alias PropertyChangedSignal = Signal!(FlexibleObject, Variant);
alias PropertyChangingSignal = Signal!(FlexibleObject, Variant*);
Variant value() @property;
Variant value(Variant) @property;
ref PropertyChangedSignal valueChanged() @property;
@MrSmith33
MrSmith33 / gist:9374266
Last active August 29, 2015 13:57
multiple binding
IProperty firstName, lastName, fullName;
// fetch properties from widgets.
auto converter = (Variant firstName, Variant lastName){
return Variant(firstName ~ " " ~ lastName);
};
fullName.pipeFrom(cast(Variant delegate(Variant[]...))converter, firstName, lastName);
dasm < stmt* eoi
lines <- (stmt )*
stmt <- basicOpcode / specOpcode / preStmt
preStmt <-
basicOpcode <- opcode expr, expr
specOpcode <- opcode expr
expr <- Arithmetic / Id
Id <-
.include "file"
@MrSmith33
MrSmith33 / moddable.d
Last active August 29, 2015 14:07
A draft of modular application engine.
module moddable;
import std.stdio;
import std.exception : enforce;
import std.datetime;
import core.thread : Thread;
/// Basic module interface.
interface IModule
module sharedmodule;
import imodule;
class SharedModule : IModule
{
override string name() @property { return "SharedModule"; }
override string semver() @property { return "0.1.0"; }
override void load() {}
module modular.modules.eventdispatchermodule;
import modular;
// Basic event
abstract class Event
{
bool continuePropagation = true;
}
@MrSmith33
MrSmith33 / app.bat
Last active August 29, 2015 14:08
Module loading
dmd -debug -g app.d imodule.d
del app.obj
@MrSmith33
MrSmith33 / tinyc.d
Created November 3, 2014 13:56
Tiny C
/* file: "tinyc.d" */
/* Copyright (C) 2001 by Marc Feeley, All Rights Reserved. */
// D port by Mr.Smith (C) 2014
import std.stdio;
import std.algorithm : equal;
/*
* This is a compiler for the Tiny-C language. Tiny-C is a