Skip to content

Instantly share code, notes, and snippets.

@cbaggers
cbaggers / NTuple.cs
Created January 9, 2022 20:35
ntuple thing
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Value Tuples that are blittable and so can be used in Unity's Jobs
// Replace with HashCode with System.HashCode when available
namespace Foo.Unmanaged
{
public static class NTuple
@cbaggers
cbaggers / epgsql_codec_emote_slot_override_v0.erl
Created July 11, 2021 02:01
epgsql user defined type codec
%% I do not know if this is the right way to do this, but I didn't find an example
%% of how to do it properly :)
-module(epgsql_codec_emote_slot_override_v0).
-behaviour(epgsql_codec).
-include_lib("vanguard/include/ale.hrl").
-export([init/2, names/0, encode/3, decode/3, decode_text/3]).
@cbaggers
cbaggers / hmm.lisp
Created August 31, 2019 22:22
nothing much
(PROGN
(DECLAIM (FTYPE (FUNCTION NIL SINGLE-FLOAT) BLOOP))
(DEFUN BLOOP ()
(THE SINGLE-FLOAT (BITS-SINGLE-FLOAT -4194304))))
@cbaggers
cbaggers / play-with-morton-codes.lisp
Created August 27, 2019 16:17
packing three u16s into a 42bit morton code
(defun u! (x y z)
(check-type x (unsigned-byte 16))
(check-type y (unsigned-byte 16))
(check-type z (unsigned-byte 16))
(make-array 3 :element-type '(unsigned-byte 16)
:initial-contents (list x y z)))
(defun u3-to-morton (u3)
(let ((x (aref u3 0))
@cbaggers
cbaggers / hmm.lisp
Last active April 5, 2019 11:12
Making circular list in print-object fails to print even when *print-circle* is T
(eval-when (:compile-toplevel :load-toplevel :execute)
(setf *print-circle* t))
#||
How to trigger issue:
First run (make-instance 'trigger-object) to see the overflow.
Then run (make-circular) to see that the list created in print-object
@cbaggers
cbaggers / psqlcp.app.src
Created December 24, 2018 00:08 — forked from w495/psqlcp.app.src
Postgresql connection pool with poolboy
{application, psqlcp, [
{description, "Postgresql connection pool with poolboy"},
{vsn, "0.1"},
{applications, [kernel, stdlib]},
{modules, [psqlcp, psqlcp_worker]},
{registered, [psqlcp]},
{mod, {psqlcp, []}},
{env, [
{pools, [
{fk, [
#include <ApplicationServices/ApplicationServices.h>
#include <Cocoa/Cocoa.h>
@interface BlortAppDelegate : NSObject <NSApplicationDelegate>
@end
@implementation BlortAppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSLog(@"applicationDidFinishLaunching");
@cbaggers
cbaggers / blort.lisp
Last active April 19, 2018 10:52
Smaller test case
#+sbcl
(eval-when (:compile-toplevel :load-toplevel :execute)
(sb-int:set-floating-point-modes :traps nil))
(defpackage :a (:use :cl))
(in-package :a)
(cffi:define-foreign-library blort
(:darwin "/Users/Baggers/Library/Developer/Xcode/DerivedData/blort-ewxiurstjoibccbijgkxqrtyvtbu/Build/Products/Debug/libblort.dylib"))
#+sbcl
(eval-when (:compile-toplevel :load-toplevel :execute)
(sb-int:set-floating-point-modes :traps nil))
(defpackage :moo (:use :cl))
(in-package :moo)
(cffi:define-foreign-library libsdl2
(:darwin (:or (:framework "SDL2") (:default "libSDL2")))
@cbaggers
cbaggers / gist:caeba24cdc9ceff164feadcc876b25c9
Last active April 15, 2018 01:13
kill cl-sdl2 on sbcl
#+sbcl
(eval-when (:compile-toplevel :load-toplevel :execute)
(sb-int:set-floating-point-modes :traps nil))
(defpackage :moo (:use :cl :sdl2))
(in-package :moo)
(defun print! (x &rest args)
(format t "~%~a~{ ~s~}" x args)