Skip to content

Instantly share code, notes, and snippets.

View BeRo1985's full-sized avatar

Benjamin Rosseaux BeRo1985

View GitHub Profile
@BeRo1985
BeRo1985 / clipline.glsl
Last active August 29, 2015 14:10
Clipping line in homogeneous coordinates
// by Benjamin 'BeRo' Rosseaux
// licensed under CC0 1.0 Universal (CC0 1.0) Public Domain Dedication ( http://creativecommons.org/publicdomain/zero/1.0/ )
void clipLineInHomogeneousCoordinates(inout vec4 pP0, inout vec4 pP1){
vec3 lWC0P = pP0.www + pP0.xyz;
vec3 lWC0S = pP0.www - pP0.xyz;
vec3 lWC1P = pP1.www + pP1.xyz;
vec3 lWC1S = pP1.www - pP1.xyz;
vec3 lTTP = lWC0P / (lWC0P - lWC1P);
vec3 lTTS = lWC0S / (lWC0S - lWC1S);
#ifdef NO_BOOLEAN_OPERATIONS
@BeRo1985
BeRo1985 / example1.asm
Last active August 29, 2015 14:27
ASM dot vs. non-dot per directive
;======================================================================
; With dot per directive
;======================================================================
.macro CopyData(Src, Dest, Count, UseRep){
.local Temp
cld
mov esi, Src
mov edi, Dest
@BeRo1985
BeRo1985 / test.c
Last active August 29, 2015 14:27
ScriptableAssembler (SASM) syntax example
/*
** Multi line comment
*/
// Single line commit
PE_SCN_CNT_CODE = 0x00000020
PE_SCN_CNT_INITIALIZED_DATA = 0x00000040
PE_SCN_CNT_UNINITIALIZED_DATA = 0x00000080
PE_SCN_MEM_EXECUTE = 0x20000000
@BeRo1985
BeRo1985 / mtent12.txt
Created August 30, 2015 07:17
FLRE benchmark
Applied on http://www.gutenberg.org/files/3200/old/mtent12.txt at a whole-
file-loaded-into-the-RAM-base on a desktop computer with a Intel Xeon
E3-1245v2 CPU and 16GB (2x8GB) DDR3-1600 unbuffered ECC RAM under Windows
8.1
Time | Match count
==============================================================================
FLRE:
@BeRo1985
BeRo1985 / FLREvsSkRegExpW.txt
Last active September 4, 2015 20:19
FLREvsSkRegExpW
==============================================================================
FLRE:
/Twain/ : 8.24 ms | 2388
/(?i)Twain/ : 8.48 ms | 2657
/[a-z]shing/ : 8.67 ms | 1877
/Huck[a-zA-Z]+|Saw[a-zA-Z]+/ : 12.02 ms | 396
/\b\w+nn\b/ : 35.54 ms | 359
/[a-q][^u-z]{13}x/ : 110.64 ms | 4929
/Tom|Sawyer|Huckleberry|Finn/ : 20.05 ms | 3015
/(?i)Tom|Sawyer|Huckleberry|Finn/ : 29.85 ms | 4820
@BeRo1985
BeRo1985 / biginttest.dpr
Last active September 8, 2015 14:32
configurable fixed-bit-size signed big integer implementation
program biginttest;
{$ifdef fpc}
{$mode delphi}
{$endif}
{$APPTYPE CONSOLE}
(******************************************************************************
* zlib license *
*============================================================================*
* *
@BeRo1985
BeRo1985 / GDFWENet.pas
Last active September 26, 2015 06:04
enet pascal port with IPv6 support
(*
**
** Copyright (c) 2002-2015 Lee Salzman
** Copyright (c) 2013-2015 Benjamin 'BeRo' Rosseaux (Pascal port and IPv6)
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and associated documentation files (the "Software"),
** to deal in the Software without restriction, including without limitation
** the rights to use, copy, modify, merge, publish, distribute, sublicense,
** and/or sell copies of the Software, and to permit persons to whom the
@BeRo1985
BeRo1985 / ringbuffer.c
Last active November 27, 2015 16:28
Lock Free Single Producer Single Consumer Ring Buffer
// Copyright (C) 2015 by Benjamin 'BeRo' Rosseaux
// licensed under CC0 1.0 Universal (CC0 1.0) Public Domain Dedication ( http://creativecommons.org/publicdomain/zero/1.0/ )
// Warning: Untested, written from scratch directly as a GitHubGist. It should only show the base idea behind it.
#define RingBufferInt int
#define RingBufferAtomicInt int
typedef int TRingBufferItem;
@BeRo1985
BeRo1985 / FLREBenchmarkResults.txt
Created February 5, 2016 08:23
New FLRE benchmark values of 05. Feburary 2015
==============================================
New FLRE benchmark values of 05. Feburary 2015
==============================================
In summary:
Delphi's 32-bit x86 code generator is better than FreePascal's 32-bit x86 code generator,
and FreePascal's 64-bit x86 code generator is better than Delphi's 64-bit x86 code
generator. The x86 inline assembler routines falls not so significant yet, i.e.
@BeRo1985
BeRo1985 / ClassIDTest1.pas
Created June 7, 2016 08:34
Enity-Component-System ComponentClassID per VMT patching
program ClassIDTest1;
{$mode delphi}
{$apptype console}
{$m+}
uses Windows,SysUtils,Classes;
type PSupraComponentClassNameID=^TSupraComponentClassNameID;
TSupraComponentClassNameID=record
Name:shortstring;