Skip to content

Instantly share code, notes, and snippets.

View serialhex's full-sized avatar
😸
Pondering language design...

serialhex

😸
Pondering language design...
View GitHub Profile
@serialhex
serialhex / containers.md
Last active December 2, 2021 19:44
My Views on Containers

My Thoughts on Containers, Containerization and Virtual Machines in general

I am writing this to express my thoughts on containers in general. I have briefly stated my surface-thoughts on them to a few people, and because it is difficult to articulate all of my thoughts at once to someone, I thought I would write a blog-post / article thing. First of all, all the opinions expressed here are mine and mine alone. There is a good chance nobody else in the world has these same thoughts, so I am alone. I'm fine with that though, as it makes me unique.

Containers are Virtual Machines

Yes. Full stop. They are. I don't care if you say they are "small" virtual machines. They are none the less, a virtual machine. From [Wikipedia, Virtual Machine]:

In computing, a virtual machine (VM) is the virtualization/emulation of a computer system. Virtual machines are based on computer architectures and provide functionality of a physical computer. Their implementations may involve specialized hardware, softwar

@serialhex
serialhex / dprism.html
Created January 3, 2020 16:37
A Damage per Round calculator for use in comparing the relative strengths of different Pathfinder 2e characters.
<!DOCTYPE html>
<html lang="en-US">
<!--
Copyright 2020 serialhex <serialhex@gmail.com>
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 Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
@serialhex
serialhex / derpyhash.c
Last active August 18, 2021 17:07
some fibonacci hash functions. 64 and 32 bit.
// this runs nicely on SMHasher
// fails a few tests, but overall is fast and passes most tests
size_t derpy_hash(const char *key, int len, uint32_t seed) {
const uint64_t *data = (const uint64_t *)key;
const uint64_t fib = 11400714819323198485llu;
// 8 bytes in a 64-bit value, so take the last 7 bits
uint8_t m = len & 7;
// initialize
param (
[string]$src = ".",
[string]$dst = ".\reencode"
)
# Add-Type -AssemblyName System.Windows.Forms
function time($block) {
$sw = [Diagnostics.Stopwatch]::StartNew()
defmodule Foobot.Repo do
# use JSON and some awesomesauce to make a database of sorts.
# in-memory it will be just a map...
# on disk JSON
# reads simply read all the data, writes do the write & also write
# a copy to disk
require Logger
@repo :repo_registry
@serialhex
serialhex / cond-<>.lisp
Last active May 18, 2017 16:39
A Common Lisp macro that threads a value through a handful of forms, updating that value if the predicate returns true.
;; from On Lisp
(defun single (lst)
(and (consp lst) (not (cdr lst))))
(defmacro cond-<> (data &body body)
"A combination of this: https://clojuredocs.org/clojure.core/cond-%3E
and this: https://github.com/rplevy/swiss-arrows#a-generalization-of-the-arrow
returns last value of <>"
(let ((<> (intern "<>")))
`(let ((<> ,data))
diff --git a/include/export.h b/include/export.h
index ca9bf47..714264b 100644
--- a/include/export.h
+++ b/include/export.h
@@ -279,6 +279,7 @@ int savePLY(ExportPoints points,
fb.open(filename, std::ios::out | std::ios::binary);
std::ostream outputStream(&fb);
std::cout << "Writing to disk...\n";
+ PLY_SCOPED_TIMER("Write");
ply.write(outputStream, true);
Working on fringe: 64
Sin address: 000000000015F6B8 Cos address: 000000000015F6B0 WPhi address: 000000000015F668 Ampl address: 000000000015F6A8 DcLevel address: 000000000015F6A0 Mod address: 000000000015F6C8
Sin address: 000000000015F6B8 Cos address: 000000000015F6B0 WPhi address: 000000000015F670 Ampl address: 000000000015F6A8 DcLevel address: 000000000015F6A0 Mod address: 000000000015F6C0
Alloc Bytes: 1536000000 Alloc Buffers: 11 Lock Bytes: 1474560000 Lock Buffers: 10
---------------------------------------------------------
| POINTER | SIZE | AF LOCK | USER LOCK |
---------------------------------------------------------
| 000000004BD90040 | 58.59 MB | Yes | No |
| 0000000022A30040 | 58.59 MB | Yes | No |
#include <arrayfire.h>
// Computes the element-wise dot product of 2 arrays
// The default of dim = -1 computes the dot for the first non-empty dimension
// otherwise, it is the dimension that the vectors are located in
array elem_dot(const array& a, const array& b, const int dim = -1) {
return sum(a * b, dim);
}
// computes the cross product of an array of vectors
this is file 2, it's sooooo much better than file 1!