Skip to content

Instantly share code, notes, and snippets.

@Altanis
Altanis / main.ino
Created December 7, 2024 15:28
robot tour code 24-25
#include <math.h>
/**
* TODO:
* Implement mechanism for strafing.
* Find the fastest way to rotate (i.e. 270 -> 0 moves 270deg left instead of 90deg right).
*/
/** A vector class which represents an (x, y) Cartesian vector. */
class Vector {
@Altanis
Altanis / hook.js
Created July 15, 2022 14:10
Memory hook for Diep.io
WebAssembly.instantiateStreaming = (r, i) => r.arrayBuffer().then(b => WebAssembly.instantiate(b, i));
const _initWasm = WebAssembly.instantiate;
WebAssembly.instantiate = (wasm, imports) => {
const loader = {raw: new Uint8Array(new Uint8Array(wasm)), buffer: new Uint8Array(wasm), imports};
_initWasm(loader.buffer, loader.imports).then(results => {
console.log(results);
const memory = Object.values(results.instance.exports).find(e => e instanceof WebAssembly.Memory);
window.HEAPF32 = new Float32Array(memory.buffer);
});
return _initWasm(wasm, imports);
@Altanis
Altanis / main.java
Created June 29, 2022 00:03
Computing the nth Degree of a Taylor Polynomial
class Main {
private static double factorial(int n) {
double result = 1;
for (int i = 1; i <= n; i++) {
result *= i;
}
return result;
}