Skip to content

Instantly share code, notes, and snippets.

@keveman
keveman / index.html
Created April 8, 2023 22:55
React Webcam Switch Camera Example
<div id="root"></div>
@keveman
keveman / op.cxx
Created July 20, 2019 23:21
outer product
#include <iostream>
#include <type_traits>
#include "peg.inl.h"
@meta void check_array(@meta const access &a) {
static_assert(std::is_array<decltype(@(a.tensor_name))>::value);
static_assert(std::rank<decltype(@(a.tensor_name))>::value == a.A.rows);
}
@macro void foo(const char* str) {
@keveman
keveman / op.cxx
Created July 19, 2019 21:51
outer product
#include <iostream>
#include "peg.inl.h"
@macro void foo(const char* str) {
@meta auto x = parse(str);
@meta x.dump(std::cout);
}
float W[32][16], x[32], y[16];
@keveman
keveman / peg.cc
Created July 18, 2019 21:04
Circle - Peglib
#include <assert.h>
#include <iostream>
#include <memory>
#include "peglib.h"
#include <vector>
#include <string>
struct matrix {
@keveman
keveman / inline.zig
Created April 19, 2019 19:17
Zig inline example
const C = struct {
x : u16,
inline fn post_inc(self: *C) u16 {
const tmp = self.*.x;
self.*.x += 1;
return tmp;
}
};
@keveman
keveman / graph_to_dot.py
Created May 7, 2018 23:36
GraphDef to DOT
def as_dot(g):
names = dict()
dot = "digraph {\n"
for op_id in sorted(g._nodes_by_id):
op = g._nodes_by_id[op_id]
parts = op.name.split("/")
n = names
for p in parts:
if p not in n:
n[p] = dict()
@keveman
keveman / keybase.md
Created April 2, 2018 15:33
keybase.md

Keybase proof

I hereby claim:

  • I am keveman on github.
  • I am keveman (https://keybase.io/keveman) on keybase.
  • I have a public key ASB03gqL5zVaMqPYEgnpURRX_GptvH_nE1MUOilG85Hj-Qo

To claim this, I am signing this object:

@keveman
keveman / church_numerals.cpp
Created February 3, 2014 23:47
Church Numerals using C++1y Generic Lambdas
#include <iostream>
template<int N> struct Int { };
auto church(Int<0>) {
return [](auto f) {
return [=](auto x) { return x; };
};
}
@keveman
keveman / gist:3521442
Created August 30, 2012 01:28
Petri net model for a program
import snakes.plugins
snakes.plugins.load('gv', 'snakes.nets', 'nets')
from nets import *
n = PetriNet('pn')
n.add_place(Place('p1', [1,2]))
n.add_place(Place('p2'))
n.add_place(Place('p3'))
n.add_place(Place('p4_i'))
@keveman
keveman / sudoku_solver.cpp
Created August 14, 2012 01:55
Sudoku solver in C++11
#include <iterator>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <iostream>
#include <cassert>
#include <memory>
#include <future>
#include <chrono>