Skip to content

Instantly share code, notes, and snippets.


Block or report user

Report or block thedeemon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
open Batteries
type point = { x : int; y : int }
let f from_y to_y from_x to_x =
let a = (from_y --^ to_y/2) |> (fun y -> {x=from_x; y=y}) in
let b = (to_y/2 --^ to_y) |> (fun y -> {x=to_x; y=y}) in
Enum.append a b |> Array.of_enum;;
let g from_y to_y from_x to_x =
let t = to_y/2 in
Array.init (to_y - from_y) (fun i -> let y = i + from_y in if y < t then {x=from_x; y=y} else {x=to_x;y=y});;
View tox.d
import std.stdio, std.algorithm, std.range, std.array, std.datetime.stopwatch;
struct Point { int x, y; }
auto f(int from_y, int to_y, int from_x, int to_x) {
return chain( iota(from_y, to_y/2).map!(y => Point(from_x, y)),
iota(to_y/2, to_y) .map!(y => Point(to_x, y)) ).array;
auto g(int from_y, int to_y, int from_x, int to_x) {
View cothinkers3.hs
import qualified Data.ByteString.Lazy.Char8 as L8
import Network.HTTP.Client (defaultManagerSettings, newManager)
import Network.HTTP.Simple
import Network.HTTP.Client.TLS
import System.Directory
import qualified Data.Map as M
import Data.List (sortBy)
import Control.Monad
import Control.Applicative
import System.Environment
View veb.txt
next uni=8192
next uni=64
next uni=8
n for 64 = 0
case ADD|RRR:
case ADD_RRR:
if (code[ip+1]==code[ip+2]) {, dword_ptr(edi, code[ip+3]*4));
a.add(dword_ptr(edi, code[ip+1]*4), eax);
} else {, dword_ptr(edi, code[ip+2]*4));
a.add(eax, dword_ptr(edi, code[ip+3]*4));, code[ip+1]*4), eax);
View lvm2jit.cpp
#include "lvm2jit.h"
#include <stdio.h>
#include <vector>
LVM2jit::LVM2jit(int stacksize, int heapsize)
: fun(NULL)
frame = (int*)calloc(stacksize, 1);
heap = (BYTE*)calloc(heapsize, 1);
callstack = (context_t*)calloc(10000, sizeof(context_t));
thedeemon / lvm2.d
Created Nov 21, 2018
bytecode VM targeted by Leo compiler
View lvm2.d
module lvm2;
import std.stdio;
enum MODSHIFT = 8;
enum RRR = 0 << MODSHIFT;
enum RRP = 1 << MODSHIFT;
enum RRV = 2 << MODSHIFT;
enum RPR = 4 << MODSHIFT;
enum RPP = 5 << MODSHIFT;
thedeemon / okserver.pony
Created Jun 22, 2018
Simple server returning same HTTP answer to all queries.
View okserver.pony
use "net"
class MyTCPConnectionNotify is TCPConnectionNotify
fun ref received(conn: TCPConnection ref, data: Array[U8] iso, times: USize) : Bool =>
conn.write("HTTP/1.0 200 OK\nContent-Type: text/html; charset=utf-8\n\nOK\n")
fun ref connect_failed(conn: TCPConnection ref) =>
thedeemon / trig_test.d
Last active May 14, 2018
Test sin & cos speed
View trig_test.d
import std.stdio, std.math;
void main() {
double s = 0;
foreach(i; 0..50_000_000) {
double t = i / 100.0;
s += sin(t)*cos(t)*200.0;
thedeemon / picture.d
Last active Feb 14, 2018
dlangui motion picture
View picture.d
module motionpicture;
import std.stdio, std.algorithm : min;
import dlangui, dlangui.widgets.metadata;
class MotionPicture : ImageWidget {
ColorDrawBuf cdbuf;
int W = 16*30, H = 9*30; //current size
this() {
setSize(W, H, true);
You can’t perform that action at this time.