Skip to content

Instantly share code, notes, and snippets.

Avatar
😸

serialhex

😸
View GitHub Profile
@serialhex
serialhex / dprism.html
Created Jan 3, 2020
A Damage per Round calculator for use in comparing the relative strengths of different Pathfinder 2e characters.
View dprism.html
<!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 / fib_hash.c
Last active Jan 30, 2019
some fibonacci hash functions. 64 and 32 bit.
View fib_hash.c
/* just some stuff for later, on smhasher-style hash functions
* here is the fibonacci hash, inspired by this:
* https://probablydance.com/2018/06/16/fibonacci-hashing-the-optimization-that-the-world-forgot-or-a-better-alternative-to-integer-modulo/
* oh, and this is cool also:
* https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/
* have fun!
*/
#include <stdint.h>
View upconvert.ps1
param (
[string]$src = ".",
[string]$dst = ".\reencode"
)
# Add-Type -AssemblyName System.Windows.Forms
function time($block) {
$sw = [Diagnostics.Stopwatch]::StartNew()
View repo.ex
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
A Common Lisp macro that threads a value through a handful of forms, updating that value if the predicate returns true.
View cond-<>.lisp
;; 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))
View diff.patch
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);
View arrayfire-memleak.txt
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 |
View dot-and-cross.h
#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
View file 2
this is file 2, it's sooooo much better than file 1!
View dir.cpp
#include "dir.h"
#include <arrayfire.h>
std::vector<std::string> get_tiff_files(std::string dir) {
std::regex re ("*\\.tiff?");
return Dir::re_filter(Dir::get_files_in_dir(dir), re);
}
You can’t perform that action at this time.