Skip to content

Instantly share code, notes, and snippets.

@rpav
rpav / autoglob.cmake
Created February 27, 2021 21:43
If you want cmake GLOB changes to automatically rebuild
# Is this worth the time it took to write? I doubt it.
#
# Usage:
#
# include(autoglob)
#
# autoglob(MY_GLOB [RECURSE]
# *.cpp
# *.h)
#
@rpav
rpav / cxx_features.cmake
Last active November 2, 2020 17:35
Fix things for various c++ compilers depending on your target's features
##
## Pick C++ version and features for compiler
##
## Why: Compilers require different flags for C++ standard conformance, as well
## as some requiring libraries linked for various functionality (and some later
## versions *lack* these libraries). This is an easy/extensible solution for
## such, since CMake's builtin picking is undependable.
##
## Usage:
##
@rpav
rpav / trivial-events.lisp
Created May 17, 2017 14:55
Trivial event handler
(defparameter *handlers* (make-hash-table))
(defun register (ev fun)
(vector-push-extend fun (alexandria:ensure-gethash
ev *handlers*
(make-array 1 :fill-pointer 0
:adjustable t))))
(defun send (type msg from)
(let ((handler-list (gethash type *handlers*)))
# This goes in AppData\Roaming\Blender Foundation\Blender\2.78\scripts\presets\operator\export_scene.fbx\ue4.py
# I've used these settings to export to UE4, but no guarantees. ;)
# Also you might need: op.bake_anim_force_startend_keying = True
op = bpy.context.active_operator
op.filepath = '...'
op.axis_forward = '-Z'
op.axis_up = 'Y'
op.version = 'BIN7400'
op.ui_tab = 'MAIN'
@rpav
rpav / coerce2.cpp
Created July 14, 2016 15:46
Better COERCE. Pick and return a function which we can reuse. Considerably faster.
#include <stdint.h>
#include "cpk++/log.hpp"
typedef int8_t i8;
typedef uint8_t u8;
typedef int16_t i16;
typedef uint16_t u16;
typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
@rpav
rpav / coerce.cpp
Last active July 14, 2016 13:48
COERCE in mostly C, with a bit of C++ for utility
#include <stdlib.h>
#include <stdint.h>
#include <cpk++/log.hpp>
typedef int8_t i8;
typedef uint8_t u8;
typedef int16_t i16;
typedef uint16_t u16;
typedef int32_t i32;
;; This assumes conspack, salza2, and chipz are loaded
(defun compress (thing)
(cpk:encode
(salza2:compress-data (cpk:encode thing)
'salza2:gzip-compressor)))
(defun decompress (thing)
(cpk:decode (chipz:decompress nil 'chipz:gzip thing)))
@rpav
rpav / tilemap-loader.lisp
Created May 2, 2016 19:34
Common Lisp loader code for Tiled map editor JSON format (tilesets and maps)
(defparameter *tileset-cache* (make-hash-table :test 'equal))
;; TILE, TILESET
(defclass tile ()
((props :initform nil :accessor props)
(image :initform nil :initarg :image :reader tile-image)))
(defclass tileset ()
((props :initform nil :accessor props)
@rpav
rpav / say.lisp
Last active August 29, 2015 14:16
:say macro for print debugging
;; (:say foo bar)
;; => FOO = <VALUE>, BAR = <VALUE>
;; (:say (:val foo))
;; => <VALUE>
;; (:say (:val foo) (:val bar))
;; => <VALUE><VALUE>
;; (:say (:val foo) " " (:val bar))
@rpav
rpav / gist:06525c5c902938c1ddae
Created October 9, 2014 03:06
Abbreviated parsing example
(defparameter *input-string*
"(tiles 2 2
(tile 0 0 TTERMLTERM EMPTY16X2 0)
(tile 1 1 TL UL 7
(primitive_site RLL_X0Y25 RESERVED_LL internal 8)
(primitive_site DCI7 DCI internal 13)
(primitive_site DCI0 DCI internal 13)
(primitive_site PMV PMV internal 8)
(primitive_site DCIRESET7 DCIRESET internal 1)
(primitive_site DCIRESET0 DCIRESET internal 1)