Skip to content

Instantly share code, notes, and snippets.

View funnbot's full-sized avatar

Dillon Bayless funnbot

  • San Francisco Bay Area
  • 07:21 (UTC -07:00)
View GitHub Profile
@funnbot
funnbot / lib.js
Created June 16, 2018 06:38
2 rpio 4 wiringpi
const rpio = require("rpio")
const pins = {
NRSTPD: 25, // GPIO 25
MAX_LEN: 16,
PCD_IDLE: 0x00,
PCD_AUTHENT: 0x0E,
PCD_RECEIVE: 0x08,
PCD_TRANSMIT: 0x04,
@funnbot
funnbot / snake.cpp
Created March 8, 2019 23:49
Mostly working cross platform snake game in console that requires sfml on mac.
#if defined(WIN32) || defined(_WIN32)
#define iswin
#endif
#include <iostream>
#include <vector>
#include <ctime>
#include <string>
#include <stdlib.h>
@funnbot
funnbot / robot_arm.ino
Last active April 2, 2020 03:42
Messing around with inverse kinematics,
#include <Servo.h>
#define P(m) (Serial.print(m));
#define PLN (Serial.println(" "))
const int BASE_PIN = 3,
ARM1_R_PIN = 5, ARM1_L_PIN = 6,
ARM2_R_PIN = 9, ARM2_L_PIN = 10;
enum ServoID {
@funnbot
funnbot / zig_gen_typings.js
Created June 15, 2020 03:16
Generate typescript d.ts typings from the exported functions in a zig file, useful for targeting web assembly and having autocomplete.
#!/usr/bin/env node
const fs = require('fs');
// mmm tasty regex
const definRegex = /export\s+fn\s+([A-Za-z_][A-Za-z0-9_]*)\s*\(((\s*([A-Za-z_][A-Za-z0-9_]*)\s*:\s*(.+?),?)*)\)\s*(.+?)[ \n\r{]+?/g;
const paramRegex = /\s*([A-Za-z_][A-Za-z0-9_]*)\s*:\s*([^,]+),?/g;
run(process.argv);
@funnbot
funnbot / vec.zig
Last active September 13, 2024 21:35
Vector types and functions for ziglang
const std = @import("std");
const Random = std.rand.Random;
const meta = std.meta;
const math = std.math;
/// Random value in [0, 1)
inline fn randomNum(comptime T: type, rand: *Random) T {
return switch (@typeInfo(T)) {
.Float, .ComptimeFloat => rand.float(T),
.Int, .ComptimeInt => @compileError("Same as VecT.zero."),
/*
// From cuda docs:
__device__ int __dp4a ( int srcA, int srcB, int c )
Four-way signedint8 dot product with int32 accumulate.
Description
Extracts four pairs of packed byte-sized integers from scrA and srcB, then creates four pairwise products and adds them together to a signed 32-bit integer c.
*/
static __device__ __forceinline__ int32_t __dp4a(int32_t srcA, int32_t srcB, int32_t c) {
return amd_mixed_dot(srcA, srcB, c, /*saturate=*/ true);