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 / Building freetype 2.5.3 dll.md
Last active August 29, 2015 14:09
How to build a dll for freetype 2.5.3 to use with DerelictFT
  1. Go to freetype-2.5.3\include\config folder and open ftoption.h file.
  2. Inside add following lines. You may do it at DLL export compilation section, or anywhere else.
#define FT_EXPORT(x) __declspec(dllexport) x
#define FT_EXPORT_DEF(x) __declspec(dllexport) x
  1. Open Visual Studio 2010, and load freetype.sln from the freetype-2.5.3\builds\win32\vc2010 directory.
  2. Open the project config, and in the General tab, change Configuration Type to Dynamic Library (.dll).
  3. Change the project compilation configuration to Release.
  4. Add following files to the project (Source Files -> Add existing). Derelict loads FT_Get_BDF_Charset_ID and provided sln file doesn't contain that file, so you need to add it. (Similarly you can add any other file if it will be needed in any more recent version of DerelictFT).