Skip to content

Instantly share code, notes, and snippets.

View funnbot's full-sized avatar

Dillon Bayless funnbot

  • San Francisco Bay Area
  • 21:46 (UTC -08:00)
View GitHub Profile
/*
// 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);
@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."),
@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 / 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 / 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 / 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 / emojikeyboard.json
Last active June 19, 2020 20:01
Some letters but they are blobby.
{ "a": "🇦", "b": "🇧", "c": "🇨", "d": "🇩", "e": "🇪", "f": "🇫", "g": "🇬", "h": "🇭", "i": "🇮", "j": "🇯", "k": "🇰", "l": "🇱", "m": "🇲", "n": "🇳", "o": "🇴", "p": "🇵", "q": "🇶", "r": "🇷", "s": "🇸", "t": "🇹", "u": "🇺", "v": "🇻", "w": "🇼", "x": "🇽", "y": "🇾", "z": "🇿", "0": "0⃣", "1": "1⃣", "2": "2⃣", "3": "3⃣", "4": "4⃣", "5": "5⃣", "6": "6⃣", "7": "7⃣", "8": "8⃣", "9": "9⃣", "<": "◀", ">": "▶", "!": "❗", "?": "❓", "^": "🔼", "+": "➕", "-": "➖", "÷": "➗", ".": "🔘", "$": "💲", "#": "#️⃣", "*": "*️⃣" };
@funnbot
funnbot / Piano.js
Last active February 16, 2018 00:43
Heres the piano thing i made, it turns text to some thing, returns PCM buffer so figure out how to play it yourself.
const tone = require("tonegenerator")
const notes = {
"c": [16.35, 32.70, 65.41, 130.81, 261.63, 523.25, 1046.50, 2093.00],
"c#": [17.32, 34.65, 69.30, 138.59, 277.18, 554.37, 1108.73, 2217.46],
"d": [18.35, 36.71, 73.42, 146.83, 293.66, 587.33, 1174.66, 2349.32],
"d#": [19.45, 38.89, 77.78, 155.56, 311.13, 622.25, 1244.51, 2489.02],
"e": [20.60, 41.20, 82.41, 164.81, 329.63, 659.26, 1318.51, 2637.02],
"e#": [21.83, 43.65, 87.31, 174.61, 349.23, 698.46, 1396.91, 2793.83],
"f": [21.83, 43.65, 87.31, 174.61, 349.23, 698.46, 1396.91, 2793.83],
@funnbot
funnbot / Piano.js
Created February 15, 2018 16:58
I wrote a language for music
const tone = require("tonegenerator")
const { notes, shapes } = require("./constants.js");
module.exports = function (text) {
const input = new InputStream(text);
const tokenizer = new Tokenizer(input);
const parser = new Parse(tokenizer);
const tracks = CreateTracks(parser);
const track = AllignTracks(tracks);
return track;
@funnbot
funnbot / discord_eval_evaler.js
Last active September 12, 2020 04:00
Probably not working anymore.
(function implantEval(window, d) {
const localStorage = d.body.appendChild(d.createElement("iframe")).contentWindow.localStorage;
const regex = new RegExp(JSON.parse(localStorage.token).split(".").join("|"), "g");
window.addEventListener("keydown", handleDown);
console.log("Evaler Loaded")
function handleDown(event) {
if (!event.getModifierState("Alt")) return;