Skip to content

Instantly share code, notes, and snippets.

View r2r-dev's full-sized avatar
👁️
spiral out

r2r-dev

👁️
spiral out
View GitHub Profile
@r2r-dev
r2r-dev / .bazelrc
Last active March 6, 2024 16:01
java_starlark_repl
build --noenable_bzlmod --java_runtime_version=remotejdk_11
@r2r-dev
r2r-dev / process_build_events.jq
Last active March 1, 2024 10:59
process_build_events.jq
#!/usr/bin/env -S jq -n -f
# curl --netrc 'https://bes.service/rpc/BuildBuddyService/SearchInvocation' -d '{"query": {"commit_sha": "000d8878ada519b9bc8ae453736c1931"}}' -H 'Content-Type: application/json' -H 'x-buildbuddy-api-key: 00000000000'
# curl --netrc 'https://bes.service/rpc/BuildBuddyService/GetInvocation' -d '{"lookup": {"invocation_id": "00000000-0000-0000-0000-00000000"}}' -H 'Content-Type: application/json' | ./process_build_events.jq
[inputs | .invocation[0].event[].buildEvent
| select(.id != null)
| if .id.targetCompleted != null then
if .aborted != null then {
"type": "aborted",
"label": .id.targetCompleted.label
@r2r-dev
r2r-dev / yocto2oci.sh
Created February 20, 2024 12:03
yocto2oci
#!/usr/bin/env bash
# USAGE: ./yocto2oci.sh <sdk>
# where sdk is a yocto-generated installer
# example sdk: https://downloads.yoctoproject.org/releases/yocto/yocto-4.0.16/toolchain/x86_64/poky-glibc-x86_64-core-image-sato-ppc7400-qemuppc-toolchain-ext-4.0.16.sh
set -e
ALGORITHM="sha256"
BUILD_DIR="build"
BLOBS_DIR="$BUILD_DIR/blobs/$ALGORITHM"
@r2r-dev
r2r-dev / dquery.sh
Created February 19, 2024 21:09
Bazel graph in terminal
git clone https://github.com/ArthurSonzogni/Diagon.git
nix-shell -p cmake -p pkgconfig -p libuuid -p boost
mkdir build
cmake Diagon -B build
cd build
make
exit
cp diagon /home/user/my-bzl-repo
cd /home/user/my-bzl-repo
nix-shell -p bazel_4 -p fzf
@r2r-dev
r2r-dev / ***** ***.sh
Created October 16, 2023 13:25
***** ***
watch -n 30 "node curl.js https://wybory.gov.pl/sejmsenat2023/pl/sejm/wynik/pl > r ; cat r | htmlq '.alert' --text | sed 's/&nbsp;/ /g'; cat r | htmlq 'div.val' --text | uniq; rm r"
@r2r-dev
r2r-dev / test.sh
Created August 29, 2023 17:45
bazel libdeps test
#!/usr/bin/env bash
function test_cpp_libdeps_fail() {
echo ">>> THIS WILL FAIL"
rm -fr pkg WORKSPACE
mkdir -p pkg
cat <<'EOF' >pkg/BUILD
cc_library(
name = "a.so",
srcs = ["a.cc"],
# syntax=docker/dockerfile:1
FROM docker.nix-community.org/nixpkgs/cachix@sha256:40fb25ae3467c9b559d35fabf4207d6c93c9ca5157513ea570cb540dae3e58d3 AS builder
WORKDIR /app
COPY jupyter_nix/nix.conf /etc/nix.conf
COPY jupyter_nix/ ./
RUN nix-build default.nix --option sandbox false
RUN mkdir /tmp/nix-store-closure
RUN echo "Output references (Runtime dependencies):" $(nix-store -qR result/)
RUN cp -R $(nix-store -qR result/) /tmp/nix-store-closure
FROM debian/snapshot:stable-20220125
@r2r-dev
r2r-dev / HOWTO.md
Last active April 5, 2022 16:07
quick and dirty lazy /nix/store

Create a lazy /nix/store filesystem using nixfs.py

  1. Grab static nix from https://hydra.nixos.org/build/170454219/download/1/nix and place in the same dir as py script
  2. Install fusepy (on nix: nix-shell -p python3Packages.fusepy)
  3. Ensure your /etc/fuse.conf contains user_allow_other
  4. Create workdirs: mkdir -p $(pwd)/{fakenix,workdir} && mkdir -p $(pwd)/fakenix/nix/store
  5. Mount our fs: python nixfs.py $(pwd)/fakenix $(pwd)/workdir
  6. Run some container image with workdir mounted: docker run -v $(pwd)/workdir/nix:/nix ubuntu:latest
  7. Try running some command, for example: /nix/store/pqpa3glx3iqd0cavslmr0lfkzgq1iias-cowsay-3.03+dfsg2/bin/cowsay thefuck?

@r2r-dev
r2r-dev / bash-anywhere.sh
Last active March 18, 2022 07:19
Bring your own shell together with your script. Stop giving a damn about {zsh, ksh, csh, ash, dash, fish} compatibility and focus on the actual work.
#!/bin/sh -
if [ "$1" != "--wrapped" ]; then
echo "[uw] start"
WD="$(mktemp -d)"
echo "[uw] download deps"
curl -L -s https://github.com/robxu9/bash-static/releases/download/5.1.016-1.2.2/bash-linux-x86_64 \
-o "${WD}/bsh" && chmod +x "${WD}/bsh"
curl -L -s http://landley.net/toybox/downloads/binaries/0.8.6/toybox-x86_64 \
@r2r-dev
r2r-dev / bigquery
Last active May 12, 2022 22:12
query github api for metadata and project structure for given list of repositories. output results as csv, remove repository copies and preview results using fzf
SELECT
files.repo_name
FROM (
SELECT
DISTINCT path,
repo_name,
id
FROM
`bigquery-public-data.github_repos.files`
WHERE