Skip to content

Instantly share code, notes, and snippets.

View dkorpel's full-sized avatar

Dennis dkorpel

  • The Netherlands
View GitHub Profile
@dkorpel
dkorpel / kuratsubaBufferSize.d
Last active January 11, 2020 12:12
Some test code for checking the buffer size needed for karatsuba multiplication in std.internal.math.biguintcore.d of Phobos
// See:
// https://issues.dlang.org/show_bug.cgi?id=20493
import std;
void main() {
foreach(i; 2..10_000) {
if ((i % 1000) == 0) writeln("i: ", i);
foreach(j; cast(int) (i * 0.7)..i) {
check(i, j, i*8/4);
}
@dkorpel
dkorpel / DstringLiteralUsage.csv
Last active March 4, 2024 01:47
A breakdown for each dub project how many of each type of string literal appears in its source files.
name “double quote” `back tick` r”r string” q{tokens} q”<brackets>” q”EOS ident EOS” x”0A 54 5C” unidentified
_ 4 0 0 0 0 0 0 0
a4g 8 0 0 0 0 0 0 0
aammm 381 2 1 0 0 0 0 0
accessors 87 6 0 0 0 0 0 0
acme-lw-d 246 0 0 0 3 0 0 0
action-pack 152 0 0 0 0 0 0 0
ae-graphics 230 16 0 26 0 0 10 0
ae 6002 356 0 203 13 7 0 0
aedi-property-reader 1731 0 0 11 0 0 0 0

List of dub packages using extern(...) in mixin templates

Context: Issue 20012 - export inside mixin doesn't seem to work

By parsing all .d files in all 1584 currently registered and available git repositories on Dub using libdparse, it was found that 13 packages have a LinkageAttribute inside a MixinTemplateDeclaration. The total number of mixin templates is 1497. Note: libdparse crashed on dmd's test suite, so dmd was skipped, but that shoudln't be important. Below is an overview for each package why extern() is used, with a link to one of the instances where it's used:


@dkorpel
dkorpel / blenderExportIndexed.py
Created April 28, 2019 19:42
A Blender Python script to export meshes for OpenGL tinkering
# Export script that takes the selected mesh and puts its vertex data (position, normal, uv)
# and indices of triangles on the clipboard and in the console
#
# > Why not just export to obj and read that?
# Proper obj reading requires you to deal with a lot of stuff:
# - separate indices for position, normal and uv, that need to be duplicated for an OpenGL VBO
# - 1-indexing
# - materials, objects, other things
#
# https://docs.blender.org/api/blender_python_api_2_73_release/bpy.types.MeshPolygon.html
/*
.:SM64 Hitbox view hack:.
April 2018
This one-time RAM-modification displays collision triangles and object cylinders in Super Mario 64.
With L + D-pad up you toggle cylinders, with L + D-pad down you toggle collision triangles.
Compiled with: https://github.com/notwa/lips
Save this file as 'hitboxview.asm' in the lips folder, and create a Lua script 'apply_hitboxhack.lua':
```
local lips = require "lips.init"
@dkorpel
dkorpel / Generate_DLL_function_pointers.d
Last active March 8, 2018 13:46
D code that generates function pointers to DLL functions when a struct with declarations is given. It can be used when you don't want to manually generate all the boilerplate for it and you don't want to use an import library.
// Member function names and signatures correspond to those in the DLL
struct FunctionsInMyDLL {
int getVersion();
string getName();
// more functions
}
import std.traits: ReturnType, Parameters, fullyQualifiedName;
// This template generates a C function pointer type from a member function in the struct