Skip to content

Instantly share code, notes, and snippets.

View rrbutani's full-sized avatar
🐢
slowly but surely

Rahul Butani rrbutani

🐢
slowly but surely
  • 00:53 (UTC -07:00)
View GitHub Profile
@rrbutani
rrbutani / ba
Last active October 6, 2021 17:24
a bad attempt at trying to trying to host an array with the frames from bad apple in it to try to shove < into tixy.land
[[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0,
@rrbutani
rrbutani / progress.sh
Last active December 31, 2020 05:50
███████████████
#!/usr/bin/env bash
readonly BOLD='\033[0;1m'
readonly CYAN='\033[0;36m'
readonly GREY='\033[0;90m'
readonly GREEN='\033[0;32m'
readonly NC='\033[0m' # No Color
# $1: start; $2: curr; $3: total
// runtime-length-varargs.c
#include <stddef.h>
#include <stdint.h>
#include <stdarg.h>
#include <stdio.h>
// In C:
int foo(size_t len, ...) {
va_list args;
va_start(args, len);
@rrbutani
rrbutani / arghhh.md
Last active October 14, 2021 20:49
bazel.md

Extremely unclear to me what the difference between some of the @rules_cc and @bazel_tools things are supposed to be:

@bazel_tools @rules_cc
@bazel_tools//tools/cpp:current_cc_toolchain @rules_cc//cc:current_cc_toolchain
@bazel_tools//tools/cpp:toolchain_utils.bzl:find_cpp_toolchain @rules_cc//cc:find_cc_toolchain.bzl:find_cc_toolchain
@bazel_tools//tools/cpp:toolchain_type @rules_cc//cc:toolchain_type

@rules_cc//cc:find_cc_toolchain.bzl:find_cc_toolchain returns a CcToolchainInfo (documented here). @bazel_tools//tools/cpp:toolchain_utils.bzl:find_cpp_toolchain claims it returns a CcToolchainProvider ([not officia

# $1: float, $2: override
function f2b() {
${2-python3} - << EOF
import struct, sys
from termcolor import colored
c = lambda s, col: colored(s, col) if sys.stdout.isatty() else s
def binary(num):
b = bin(struct.unpack('!I',struct.pack('!f', num))[0])
return b.replace('0b', '').rjust(32, '0')
o = binary($1)
function instrument {
local state e
state=$(set +o | xargs -L1 echo ' ') # prefix with spaces so these don't pollute the history
set -x
"${@}";
{ e=$?; set +x; } 2>/dev/null
eval "${state}"
return $e
@rrbutani
rrbutani / chk.sh
Last active March 29, 2021 10:16
💉
#!/usr/bin/env bash
readonly RED="\e[0;91m"
readonly GREEN="\e[0;92m"
readonly WHITE="\e[0;97m"
readonly BOLD="\e[1m"
readonly ULINE="\e[4m"
readonly NC="\e[0m"
set -e
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Crimes™</title>
<meta name="description" content="very bad">
<meta name="theme-color" content="#FF0000">
@rrbutani
rrbutani / .bazel_playground-cc_compiler_platform_constraint
Last active January 22, 2022 22:29
bazel playground: cc_compiler platform constraint test
###
@rrbutani
rrbutani / .bazel-toolchain_transition_test
Last active January 23, 2022 00:51
bazel toolchain_transition_test (non-native – not rules_cc)
non-native – not rules_cc
the point is to see whether we can have a toolchain depend on another toolchain of the same type (using transitions) without Bazel thinking it's a cycle
i.e. bootstrapping
the answer appears to be yes; we can do this (without needing to resort to manually running commands from a repo rule or something)
this doesn't seem to work with rules_cc; a native ruleset
but it's not super clear why