Skip to content

Instantly share code, notes, and snippets.

@prenaux
prenaux / _build.ham
Created October 25, 2022 11:46
ham rules to generate Protoc C++
# ProtocToCpp TARGET : input.proto ;
rule ProtocToCpp {
local genDir = _pb ;
local input = [ FGristFiles $(2) ] ;
local cpp = [ FGristFiles [ FDirName $(input:D) $(genDir) $(input:B).pb.cc ] ] ;
local h = [ FGristFiles [ FDirName $(input:D) $(genDir) $(input:B).pb.h ] ] ;
local outDir = [ FGetAbsolutePath [ FDirName $(input:D) $(genDir) ] ] ;
ProtocRun_ $(cpp) $(h) : $(input) : $(genDir) : $(outDir) ;
DEPENDS protoc-to-cpp : $(cpp) $(h) ;
@prenaux
prenaux / pathenv_in_ham.sh
Created July 31, 2022 15:07
Add/remove path from the PATH environment variable
pathenv_add() {
if [ ! -d "$1" ]; then
return 0
fi
DIR=$(unxpath "$1")
if [ -z "$PATH" ]; then
PATH=$DIR
elif [ -d "$DIR" ] && [[ ":$PATH:" != *":$DIR:"* ]] ; then
if [ "$2" = "after" ] ; then
export PATH=$PATH:$DIR
@prenaux
prenaux / msvc19_deadlock.cpp
Last active July 28, 2022 15:56
MSVC v19 optimiser freezes when compiling GetTrianglesIndices_MSVC19_Deadlock
//
// The MSVC 19 optimizer deadlocks when compiling GetTrianglesIndices_MSVC19_Deadlock.
// Tested on cl.exe v19.27.29112 & v19.29.30142.1
//
// See: https://godbolt.org/z/o8rWsWsbb
//
//! Get triangles indices.
//! \remark The array needs to have room for 36 elements.
static void GetTrianglesIndices_MSVC19_NoCrash(int* pIndices, bool bCW) {
@prenaux
prenaux / flecs_nilang_reflection_example.cpp
Created July 26, 2022 12:21
Flecs: Register niLang math types & component members for interop.
#define _TMEMBER(T,NAME) member<decltype(T::NAME)>(#NAME)
#define _MEMBER(NAME) member<decltype(NAME)>(#NAME)
void RegisterBaseTypes(flecs::world& aWorld) {
aWorld.component<sVec2f>()
._TMEMBER(sVec2f,x)
._TMEMBER(sVec2f,y);
aWorld.component<sVec3f>()
._TMEMBER(sVec3f,x)
._TMEMBER(sVec3f,y)
@prenaux
prenaux / add-alpine-js-to-tailwind-ui.js
Created March 18, 2022 11:02 — forked from KevinBatdorf/add-alpine-js-to-tailwind-ui.js
Auto copy the Alpine code from Tailwind UI's copy button
// ==UserScript==
// @name Add AlpineJs to Tailwind UI
// @namespace http://tampermonkey.net/
// @version 3.0
// @description Add Alpine JS code to Tailwind Ui copy/paste
// @author https://gist.github.com/KevinBatdorf/8bd5f808fff6a59e100dfa08a7431822
// @match https://tailwindui.com/components/*
// @grant none
// ==/UserScript==
@prenaux
prenaux / polyglot-mode.el
Created May 1, 2020 12:46
Super basic emacs mode for Polyglot/SableCC grammars
(defvar polyglot-mode-hook nil)
(defconst polyglot-mode-syntax-table
(let ((table (make-syntax-table)))
;; SableCC uses java-style comments.
;; Follows the C++ example in the major mode tutorial
;; //. /*...*/
(modify-syntax-entry ?/ ". 124b" table)
(modify-syntax-entry ?* ". 23" table)
(modify-syntax-entry ?\n "> b" table)
#
# Sample configuration file for the Samba suite for Debian GNU/Linux.
#
#
# This is the main Samba configuration file. You should read the
# smb.conf(5) manual page in order to understand the options listed
# here. Samba has a huge number of configurable options most of which
# are not shown in this example
#
# Some options that are often worth tuning have been included as
@prenaux
prenaux / dot-emacs.el
Created August 30, 2018 04:43
Polyglot mode for Emacs
(autoload 'polyglot-mode "polyglot-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.polyglot\\'" . polyglot-mode))
(add-to-list 'auto-mode-alist '("\\.productions\\'" . polyglot-mode))
(add-to-list 'auto-mode-alist '("\\.sablecc\\'" . polyglot-mode))
@prenaux
prenaux / sensible-defaults.css
Created June 2, 2018 12:15 — forked from cesarandreu/sensible-defaults.css
Sensible css defaults taken from css-layout
div, span {
box-sizing: border-box;
position: relative;
display: flex;
flex-direction: column;
align-items: stretch;
flex-shrink: 0;
align-content: flex-start;
@prenaux
prenaux / MagicMove.jsx
Created August 30, 2015 06:55
An updated MagicMove.jsx, faster than react-shuffle, but has issues with overlays and resizing, atm I'm using react-shuffle because of that.
var React = require('react');
var cloneWithProps = require('react/lib/cloneWithProps');
var Clones = React.createClass({
displayName: 'MagicMoveClones',
propTypes: {
children: React.PropTypes.node,
},