Skip to content

Instantly share code, notes, and snippets.

[snip]
.text
.globl module_test7_add_of_function_to_sys_int_of_sys_int_and_sys_int
.type module_test7_add_of_function_to_sys_int_of_sys_int_and_sys_int, @function
module_test7_add_of_function_to_sys_int_of_sys_int_and_sys_int:
pushl %ebp
movl %esp, %ebp #mov4.2
.L106_entry:
pushl $0
movl 12(%esp), %eax #mov4.2
void sendPlayerPosLook(double x, y, z, float yaw, pitch, bool onGround) {
byte[auto~] data;
data ~= toField &x;
data ~= toField double:(y + 2);
data ~= toField &y;
data ~= toField &z;
data ~= toField &yaw;
data ~= toField &pitch;
data ~= *byte*:&onGround;
sendPacket(0x0d, data[]);
module tetris;
import sdl; // For graphics output
import std.math, std.file, std.random;
extern(C) int time(int*);
// Board size. size[0] is x is horizontal. size[1] is y is vertical.
alias size = (7, 14);
module pyramid;
import opengl, glsetup;
import sdl, camera;
import std.macros.switchover;
void main(string[] args) {
// resizeWindow (640, 480);
auto vertices = [vec3f (-1, -1, -1), vec3f(1, 1, 1)];
auto once-per(float t) {
auto lastrun = sec();
return new \(void delegate() task) {
auto sec = sec();
if (sec - lastrun > t) {
lastrun = sec;
task();
}
}
class Text : RectWidget, HasSizeInfo {
[...]
void setText(string s) {
provide "recomputes width";
[...]
class LinebreakText : RectWidget, HasSizeInfo {
[...]
void make-layout() {
auto mksphere(int depth) {
alias V = vec3f;
(V,V,V)[auto~] res;
if false return res[]; // return type hint
if (!depth) {
auto points = [for tup <- cross([-1, 1] x 3): V tup].eval[];
for auto tup <- [
(0, 1, 3), (0, 3, 2),
(4, 5, 7), (4, 7, 6),
module maid;
import tools.base, tools.functional, irc, dice: rand;
// returns randomized indices of maxcount top values
int[] SelectTopRand(int[] input, int count) {
if (!input.length) return null;
if (input.length == 1) return [0];
int max = input[1], maxpos;
foreach (i, v; input) if (v > max) { max = v; maxpos = i; }
module restarter;
import std.string, std.file, std.thread, std.time, std.fun;
extern(C) {
alias pid_t = int;
pid_t fork();
int execv(char* path, char** argv);
pid_t waitpid(pid_t, int* status, int options);
}
module bintest;
// assume array is sorted from small to big
int findIndexOfOne(int[] array, int value) {
if (!array.length) raise new Error "$value not found during binsearch";
auto test-idx = array.length / 2;
if (array[test-idx] == value) return test-idx;
if (array[test-idx] < value) // everything before test-idx is also smaller
return findIndexOfOne(array[test-idx+1 .. $], value) + test-idx+1;
else // everything after test-idx is also larger