Skip to content

Instantly share code, notes, and snippets.

View kazimuth's full-sized avatar
🕷️
numbers aren't real

james gilles kazimuth

🕷️
numbers aren't real
  • Detroit, MI
View GitHub Profile
@kazimuth
kazimuth / bitotal_relations.rs
Last active November 10, 2023 06:16
Counting nonsense
use std::collections::HashMap;
fn main() {
println!("Counting bitotal relations R: 1..n |<>| 1..m");
println!("i.e. id <= R ; R^T and id <= R^T ; R");
println!("(see: https://en.wikipedia.org/wiki/Relation_algebra, book: Algebra of Programming by Bird and Moore)");
println!();
println!("Equivalently, counting bipartite graphs between node sets of size n and m,");
println!("where every vertex has degree at least 1.");
println!();
using Plots, ForwardDiff, StaticArrays, Distributions, Test
g(x) = sin.(x)
function newton(g, x0, n=10)
out = zeros(length(x0), n)
x = x0
for i in 1:n
out[:, i] = x
dg = ForwardDiff.jacobian(g, x)
@kazimuth
kazimuth / test.swift
Last active September 29, 2019 20:54
import Glibc
setenv("SWIFT_TENSORFLOW_ENABLE_DEBUG_LOGGING", "true", 1)
let s = "grpc://\(String(cString: getenv("COLAB_TPU_ADDR")!))"
setenv("SWIFT_TENSORFLOW_SERVER_ADDRESS", s, 1)
print("SWIFT_TENSORFLOW_SERVER_ADDRESS:", String(cString: getenv("SWIFT_TENSORFLOW_SERVER_ADDRESS")!))
import TensorFlow
func runTestComputation() -> Tensor<Float> {
// Create two 1000x1000 tensors sampled from a random normal distribution.
@kazimuth
kazimuth / persist.py
Created May 8, 2019 05:08
filesystem persistence for python science stuff
from typing import Any, Union
import hashlib
import pandas
import numpy as np
import json
import os
from pathlib import Path
def _load_json(path: Path):
return json.load(path.open('r'))
@kazimuth
kazimuth / all-tvm-packedfuncs.txt
Created April 9, 2019 05:06
all the tvm packedfuncs and their types (if given), bc4285ddbede86a59c2d88befcacb67d041e0f76
Range: UNKNOWN
_Array: UNKNOWN
_ArrayGetItem: UNKNOWN
_ArraySize: UNKNOWN
_AttrsListFieldInfo: UNKNOWN
_BijectiveLayout: tvm::BijectiveLayout(tvm::Layout, tvm::Layout, )
_BijectiveLayout: tvm::BijectiveLayout(tvm::Layout, tvm::Layout, )
_BijectiveLayoutBackwardIndex: tvm::Array<HalideIR::Expr, void>(tvm::BijectiveLayout, tvm::Array<HalideIR::Expr, void>, )
_BijectiveLayoutBackwardIndex: tvm::Array<HalideIR::Expr, void>(tvm::BijectiveLayout, tvm::Array<HalideIR::Expr, void>, )
_BijectiveLayoutBackwardShape: tvm::Array<HalideIR::Expr, void>(tvm::BijectiveLayout, tvm::Array<HalideIR::Expr, void>, )
@kazimuth
kazimuth / mathbox.d.ts
Last active May 7, 2021 09:00
MathBox 2 Typescript type declaration file
/** MathBox type declarations (autogenerated) */
/** Matrix width */
declare interface MBArea {
/** Use (fast) integer lookups */
aligned?: boolean;
/** Axis pair */
axes?: number[];
/** Matrix buffer height */
bufferHeight?: number;
same oh
big oh
hat oh
worm oh
mood oh
oh same
big same
hat same
worm same
mood same
@kazimuth
kazimuth / system_macro.rs
Last active May 22, 2018 08:51
System impl macro for specs
use specs::System;
// Tired of writing out a bunch of giant tuples by hand?
// I have the macro for you!
struct BananaSystem;
system! {
BananaSystem;
@kazimuth
kazimuth / battlecode-oom.md
Last active January 23, 2018 21:35
Battlecode OOM Fix

Why is my Battlecode Java player saying "Killed"?

Assuming you're running in Docker, this means you're running out of memory.

An initial fix you should apply is to put -Xmx40m in your player/run.sh; see the examplefuncsplayer-java/run.sh from the current scaffold for how this should work.

Depending on how your code works, this may fix the problem. However, in some cases you may need to tune the number to be lower (for example, -Xmx10m).

Note that you should NOT set -Xmx256m or -Xmx512m; if you're curious, see the next section of this document for why setting the number so low is necessary.

In the game running interface, you can also set Player memory limit (in mb) to 512 instead of 256. In the next release we will set this to be the default, and raise the memory limit in the scrimmage servers. This should give you a little more breathing room. We'll also be tuning the engine to use less memory, c

Performance: Making things go faster

Measure twice, optimize once

How do we measure?

  • Java
    • jvisualvm
    • Can't be using docker!
  • Python