Skip to content

Instantly share code, notes, and snippets.

View MrSmith33's full-sized avatar

Andrey Penechko MrSmith33

View GitHub Profile
@MrSmith33
MrSmith33 / interfaces.d
Created March 27, 2015 23:20
voxel interfaces
alias FrameId = size_t;
struct Chunk
{
ivec4 position;
ChunkSnapshot*[] snapshots;
// returns latest (newest) snapshot that is not writeable anymore. FrameId < currentTimestamp
// returns null if no data avaliable
ChunkSnapshot* getReadableSnapshot(FrameId currentTimestamp)
@MrSmith33
MrSmith33 / milf.d
Created February 22, 2015 10:40
Lisp interpreter (by Ketmar)
/* idiotic microlisp */
//module milf is aliced;
module milf;
alias usize = size_t;
// ////////////////////////////////////////////////////////////////////////// //
class MilfException : Exception {
Cell cell;
this (string message, Cell acell=null, string file=__FILE__, usize line=__LINE__, Throwable next=null) @safe pure nothrow {
private import std.string : format;
private import std.traits;
private import std.typecons : Flag;
private import std.range : isInputRange, isOutputRange, ElementType;
private import std.typecons : isTuple;
/// Encodes value E into output range sink.
/// Returns number of bytes written to sink.
size_t encodeCbor(R, E)(auto ref R sink, E value)
if(isOutputRange!(R, ubyte))
/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: cannot find -lpthread
/usr/bin/ld: cannot find -lm
/usr/bin/ld: cannot find -lrt
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find -lc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc.a when searching for -lgcc
@MrSmith33
MrSmith33 / app.d
Last active August 29, 2015 14:12
Linux .so test
module app;
import std.stdio : writeln, writefln;
import std.string : toStringz;
import imodule;
version (Posix)
{
pragma(lib, "dl");
version (Linux)
@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).
@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
@MrSmith33
MrSmith33 / app.bat
Last active August 29, 2015 14:08
Module loading
dmd -debug -g app.d imodule.d
del app.obj
module modular.modules.eventdispatchermodule;
import modular;
// Basic event
abstract class Event
{
bool continuePropagation = true;
}
module sharedmodule;
import imodule;
class SharedModule : IModule
{
override string name() @property { return "SharedModule"; }
override string semver() @property { return "0.1.0"; }
override void load() {}