Skip to content

Instantly share code, notes, and snippets.

View MrSmith33's full-sized avatar

Andrey Penechko MrSmith33

View GitHub Profile
@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 / 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)
/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
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))
@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 {
@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 / main.d
Last active August 29, 2015 14:19
Benchmarking ints vs floats
// x86 release
// 0.000,294 secs byte
// 0.000,237 secs short
// 0.000,282 secs int
// 0.002,368 secs long
// 0.110,046 secs float
// 0.109,296 secs double
// 0.109,388 secs real
//
// x86_64 release
@MrSmith33
MrSmith33 / api.d
Last active August 29, 2015 14:27
Data driven API
struct Transform {
float x, y, z;
}
struct Velocity {
float x, y, z;
}
enum entityCountMax = 1_000_000;
enum entityCountMin = 100_000;

WorldAccess wa

Linear access

foreach(index; 0..CHUNK_SIZE_CUBE)
{
	wa.getBlock(index);
}
[Version]
version=7.51 Build 020
; environment for both 32/64 bit
[Environment]
DFLAGS="-I%@P%\..\..\src\phobos" "-I%@P%\..\..\src\druntime\import"
; optlink only reads from the Environment section so we need this redundancy
; from the Environment32 section (bugzilla 11302)