Skip to content

Instantly share code, notes, and snippets.

Avatar

Benjamin Rosseaux BeRo1985

View GitHub Profile
@BeRo1985
BeRo1985 / clipline.glsl
Last active Aug 29, 2015
Clipping line in homogeneous coordinates
View clipline.glsl
// 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 Aug 29, 2015
ASM dot vs. non-dot per directive
View example1.asm
;======================================================================
; 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 Aug 29, 2015
ScriptableAssembler (SASM) syntax example
View test.c
/*
** 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
View mtent12.txt
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:
View FLREvsSkRegExpW.txt
==============================================================================
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 Sep 8, 2015
configurable fixed-bit-size signed big integer implementation
View biginttest.dpr
program biginttest;
{$ifdef fpc}
{$mode delphi}
{$endif}
{$APPTYPE CONSOLE}
(******************************************************************************
* zlib license *
*============================================================================*
* *
@BeRo1985
BeRo1985 / GDFWENet.pas
Last active Sep 26, 2015
enet pascal port with IPv6 support
View GDFWENet.pas
(*
**
** 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 Nov 27, 2015
Lock Free Single Producer Single Consumer Ring Buffer
View ringbuffer.c
// 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 Feb 5, 2016
New FLRE benchmark values of 05. Feburary 2015
View FLREBenchmarkResults.txt
==============================================
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 Jun 7, 2016
Enity-Component-System ComponentClassID per VMT patching
View ClassIDTest1.pas
program ClassIDTest1;
{$mode delphi}
{$apptype console}
{$m+}
uses Windows,SysUtils,Classes;
type PSupraComponentClassNameID=^TSupraComponentClassNameID;
TSupraComponentClassNameID=record
Name:shortstring;