Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / gist:7832108
Last active December 30, 2015 12:49
sbcl won't finalize until the thread is done?
(defclass finalize-test () ())
(defmethod initialize-instance ((instance finalize-test) &key &allow-other-keys)
(bt:make-thread (lambda () (sleep 300)))
(tg:finalize instance
(lambda ()
(format t "I am all done.~%"))))
(make-instance 'finalize-test)
@rpav
rpav / insert-eval-button.el
Last active December 29, 2015 11:39
Insert a "button" (hyperlink) at the point that evals the code before it in slime.
(defun insert-eval-button ()
(interactive)
(insert-string " ")
(insert-text-button
"Eval" 'action
(lambda (x)
(save-excursion
(goto-char (button-start x))
(slime-eval-last-expression)))
'follow-link t))