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
@technomancy
technomancy / style.md
Last active January 22, 2024 22:45
Clojure Style Guide: commentary

The Clojure Style Guide is pretty good overall. It's very detailed and most of its advice is solid. There are handful of places it makes bad recommendations or is missing some advice.

Many of these criticisms apply to the output of linters like clj-kondo as well.

threading macros vs let

@chase-lambert
chase-lambert / chatgpt-cli.clj
Last active June 7, 2023 08:35
chatGPT API cli
#!/usr/bin/env bb
;; You need to have an OpenAI API key and set it like:
;; export OPENAI_API_KEY=<your key> in your .bashrc
;;
;; Make sure you have babashka installed
;; https://github.com/babashka/babashka#installation
;;
;; One way to run this is to install bbin
;; https://github.com/babashka/bbin

Graphics

CLJC

  • Quil Graphics and animation sketches, based on Processing
  • th.ing/geom a comprehensive and modular geometry & visualization toolkit. WebGL, OpenGL, SVG.
  • Iglu Turning data into GLSL shaders for use by OpenGL and WebGL. By Zach Oakes, part of play-cljc.

Clojure

@borkdude
borkdude / aoc21_01.clj
Last active December 22, 2021 02:32
Advent of Code 2021 - in Clojure / babashka 0.6.8
(ns aoc21-01
(:require [clojure.string :as str]))
(def input (map parse-long (str/split-lines (slurp "input.txt"))))
(defn answer-01 [input]
(count (filter true? (map < input (rest input)))))
(def three-sliding-window
(map + input (next input) (nnext input)))
@ericnormand
ericnormand / 00 Dijkstra's Algorithm.md
Created September 14, 2021 19:59
442 PurelyFunctional.tv Newsletter

Dijkstra's Algorithm

Write a function to calculate the shortest path between two nodes in a graph using Dijkstra's Algorithm. The graph is directional and is represented as a map. The keys are pairs of nodes and the value is the cost to traverse the edge between them, from the first node to the second node. If a pair of nodes does not exist in the map, it means that there is no edge between them.

Example graph

(def graph {[:a :b] 1
            [:a :c] 2
 [:c :a] 4})
@adam-james-v
adam-james-v / vidwiz.clj
Last active January 22, 2023 09:42
Clojure/babashka script to help automate some of my video editing pipeline
#!/usr/bin/env bb
(ns vidwiz.main
"This is a prototype script for automating a portion of my video editing using ffmpeg."
(:require [clojure.java.shell :refer [sh]]
[clojure.string :as st]
[cheshire.core :refer [parse-string]]))
;; util
(defn get-extension
@mmzsource
mmzsource / babashka-maze-solving-clojure-asciinema.md
Last active February 26, 2021 23:21
coding dojo - maze solving

asciicast

roots of a quadratic equation

Quadratic equations can be represented by three numbers, a, b, and c, which are the coefficient of x^2, the coefficient of x, and the constant term. The roots of a quadratic equation are everywhere where it touches the x axis, meaning the equation is equal to zero.

You can use the quadratic formula which calculates the roots. In fact, that's your task: write a function that returns the roots of a quadratic equation using the quadratic formula. Here is more information about it.

Note: you don't have to return complex roots if the curve does not cross the x-axis.

Thanks to this site for the challenge idea where it is considered Medium level in Python.

@roman01la
roman01la / clojurescript-repl-workflow.md
Last active October 22, 2022 12:07
ClojureScript REPL Workflow

ClojureScript REPL Workflow

Short write up on using REPL when developing UIs in ClojureScript.

Hot-reload on save or Eval in REPL?

Everyone's standard approach to hot-reloading is to use a tool (Figwheel or shadow-cljs) that reloads changed namespaces automatically. This works really well: you change the code, the tool picks up changed files, compiles namespaces and dependants, notifies REPL client which then pulls in compiled changes, and re-runs a function that re-renders UI.

The other approach is to use ClojureScript's REPL directly and rely only on eval from the editor. This more or less matches Clojure style workflow. This approach might be useful when you don't want tools overhead or hot-reloading becomes slow for you or you just used to this style of interactions. Also changing code doesn't always mean that you want to reload all the changes. On the other hand it is very easy to change a couple of top-level forms and forget to eval one of them.

@jrc03c
jrc03c / download-canvas-as-image.js
Created February 13, 2020 15:10
Download the contents of an HTML5 canvas as an image
function downloadCanvasAsImage(canvas, filename){
let a = document.createElement("a")
a.href = canvas.toDataURL()
a.download = filename
a.dispatchEvent(new MouseEvent("click"))
}