Skip to content

Instantly share code, notes, and snippets.

View bobbicodes's full-sized avatar
💭
Moved to bobbicodes on Codeberg

Bobbi Towers bobbicodes

💭
Moved to bobbicodes on Codeberg
View GitHub Profile
@bobbicodes
bobbicodes / tofino.clj
Created February 24, 2022 23:39
Tofino data processing
(ns tofino
(:require [clojure.string :as str]))
(defn rows [page]
(map #(str/split % #"\s+")
(str/split-lines (slurp page))))
(defn barcode [row]
(first row))
@bobbicodes
bobbicodes / ytdl.cljs
Last active February 26, 2022 03:25
Download and process YouTube videos with nbb
(ns ytdl
(:require ["ytdl-core$default" :as ytdl]
["fluent-ffmpeg$default" :as FFmpeg]
["fs" :as fs]
[promesa.core :as p]))
(defn save
"Fetches a YouTube url and writes it to a file."
[url name]
(p/let [stream (ytdl url)]
@bobbicodes
bobbicodes / audio.js
Created February 21, 2022 18:48
Pipe audio from server side to Web Audio API
// https://web.archive.org/web/20170715041035/http://www.willvillanueva.com/the-web-audio-api-from-nodeexpress-to-your-browser/
var express = require('express');
var fs = require('fs');
var ejs = require('ejs');
var path = require('path');
var app = express();
app.use(express.static(__dirname + '/public'));
@bobbicodes
bobbicodes / comp.ps1
Last active March 20, 2022 08:12
Dynamic audio compression with ffmpeg in Powershell
ffmpeg -i 'in.mp4' -af acompressor=threshold=-30dB:ratio=20:makeup=10 -c:v copy out.mp4
@bobbicodes
bobbicodes / day01.clj
Last active June 1, 2022 07:42
Advent of Code 2021 day 1
;; https://adventofcode.com/2021/day/1
(ns day01
(:require [clojure.string :as str]))
(def input (map #(Integer/parseInt %) (str/split-lines (slurp "day01.txt"))))
;; this is like levels of tired->wired etc...
;; there was a loop-based solution in https://www.youtube.com/watch?v=q_I3r0JGhR8 by onthecodeagain
;; which received some comments from Erik Grundy and Sebastian Anklamm offering a more functional solution:
@bobbicodes
bobbicodes / example.cljs
Created December 3, 2021 10:02
Use Web Audio API with nbb
(ns example
(:require ["fs" :as fs]
["web-audio-api$default" :as wa]))
(def ^:dynamic context (wa/AudioContext.))
(set! (.-outStream context) (.-stdout js/process))
(fs/readFile "outfoxing.mp3"
(fn [err buffer]
(when err (throw err))
@bobbicodes
bobbicodes / graph.clj
Created July 4, 2021 08:35
Graphviz reconstructed SVG in Hiccup
(defn svg-node [label x y]
[:g [:ellipse {:fill "none" :stroke "black" :cx x :cy y :rx 27 :ry 18}]
[:text {:text-anchor "middle" :x x :y (+ 4 y) :font-family "Monospace"
:font-size 14} label]])
(defn svg-edge [label x y path points]
[:g
[:path {:fill "none" :stroke "black" :d path}]
[:polygon {:fill "black" :stroke "black" :points points}]
[:text {:text-anchor "middle" :x x :y y :font-family "Monospace" :font-size 14.00} label]])
@bobbicodes
bobbicodes / graph.clj
Created July 4, 2021 08:29
Graphviz reconstructed SVG in Hiccup
(defn svg-node [label x y]
[:g [:ellipse {:fill "none" :stroke "black" :cx x :cy y :rx 27 :ry 18}]
[:text {:text-anchor "middle" :x x :y (+ 4 y) :font-family "Monospace"
:font-size 14} label]])
(defn svg-edge [label x y path points]
[:g
[:path {:fill "none" :stroke "black" :d path}]
[:polygon {:fill "black" :stroke "black" :points points}]
[:text {:text-anchor "middle" :x x :y y :font-family "Monospace" :font-size 14.00} label]])
(defn dag3 []
[:svg {:width "100%" :viewBox "0 0 566 305"}
[:g {:transform "scale(1,1), rotate(0), translate(4,301)"}
[:polygon {:fill "white" :stroke "none" :points "-4,4 -4,-301 562,-301 562,4 -4,4"}]
[svg-node "14" 315 -18]
[svg-node "12" 459 -18]
[svg-node "11" 171 -18]
[svg-node "10" 243 -18]
[svg-node "13" 531 -18]
[svg-node "4" 99 -105]
@bobbicodes
bobbicodes / selection.cljs
Created June 21, 2021 00:43
Selection sort toy
(ns selection
(:require [reagent.core :as r]))
(defn button [label onclick]
[:button
{:on-click onclick}
label])
(defn polygon [& points]
[:polygon