Skip to content

Instantly share code, notes, and snippets.

View adam-james-v's full-sized avatar
🏠
Working from home

adam-james adam-james-v

🏠
Working from home
View GitHub Profile
@adam-james-v
adam-james-v / hydroponic-design.cljc
Last active February 12, 2021 17:13
Design File for a DIY hydroponics system. This uses clojure and scad-clj to compile an OpenSCAD script.
;; code related to https://youtu.be/EU0_I-1ROok
(ns hydro.design
(:require [clojure.string :as st]
[scad-clj.model :refer :all]
[scad-clj.scad :refer [write-scad]]))
(def parameters
{:tube-p {:l 34
:id 5
@adam-james-v
adam-james-v / hc-main.cljc
Last active March 15, 2021 14:47
Minimal implementation of a Hiccup Compiler
;; source code related to the project shown in this video:
;; https://youtu.be/_XiEc0g2wL8
;; author: adam-james
(ns hc.main)
(defn hiccup?
[item]
(and (vector? item)
(keyword? (first item))))
@adam-james-v
adam-james-v / qblock.cljc
Last active July 13, 2022 08:33
Code for a mario Question Block Model (Clojure compiled to openscad)
;; code related to a youtube video:
;; https://youtu.be/3euk0-JF_tc
(ns qblock.main
(:require [clojure.string :as st]
[scad-clj.model :refer :all]
[scad-clj.scad :refer [write-scad]]))
(fn! 30)
@adam-james-v
adam-james-v / images-during-clojure-dev.org
Created July 18, 2022 20:25
Ways to Show Images in Emacs during Clojure Dev.

CIDER-show

Cider-show depends on CIDER’s ability to display inline images. You have to enable this feature:

M-x cider-repl-toggle-content-types

Run that command in a CIDER REPL buffer to enable the feature.

Or, permanently enable the setting by placing this somewhere in your emacs init config:

@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
@adam-james-v
adam-james-v / export-md-on-save-org-mode.el
Created April 22, 2022 04:41
Elisp function that calls Pandoc's org to markdown exporter. Useful for org+clerk literate programming
;; You can use this function to export your current .org file as a .md file
;; The function requires Pandoc to be installed, so make sure you've got it!
;; Why use this instead of org's built in markdown exporter?
;; If you're a fan of both org mode and NextJournal's Clerk, you can use this to
;; effectively have Clerk render your .org files as you write them.
;; The built-in markdown exporter does not correctly annotate code blocks
;; with ```clojure \n ... \n```, which prevents Clerk from seeing and evaluating
@adam-james-v
adam-james-v / higher-order-geom.clj
Created August 21, 2023 19:54
Higher Order Functions can be used to capture geometric data and compile to other CAD contexts simultaneously.
(ns example.geom
(:require [clojure.string :as str]))
;; Utils
(defn normalize
"find the unit vector of the given vector `v`."
[v]
(when v
(let [m (Math/sqrt ^double (reduce + (mapv * v v)))]
(mapv / v (repeat m)))))
@adam-james-v
adam-james-v / ob-babashka.el
Last active February 8, 2024 16:25
a quick change of ob-clojurescript to try use Babashka.
;;; ob-babashka.el --- org-babel functions for ClojureScript evaluation -*- lexical-binding: t; -*-
;; Author: Adam James Vermeer
;; Maintainer: Adam James Vermeer
;; Created: 25 June 2021
;; Keywords: literate programming, reproducible research, babashka, clojure, scripting
;; Homepage: https://gist.github.com/adam-james-v/f4d2b75a70b095d14a351a1eff96b4b0
;; Package-Requires: ((emacs "24.4") (org "9.0"))
;; This file is modified from [[https://github.com/emacsmirror/ob-clojurescript/blob/master/ob-clojurescript.el][ob-clojurescript]]
@adam-james-v
adam-james-v / literate-clojure-emacs-config.org
Created April 4, 2021 04:45
A minimum-viable emacs config. for literate programming with Clojure.

Emacs Config

;;

This is a ‘minimum viable config’ built for the purpose of literate programming with Clojure / Clojurescript. It uses MELPA to download and install a few packages that I consider necessary for a good Clojure dev. experience, though that’s of course only my opinion. I use CIDER, a robust and popular REPL tool. It could arguably be substituted for inf-clojure, but I haven’t tried that myself.

This config does assume that you already have emacs installed and that you have at least a cursory understanding of how to navigate and use it. Or, at the very least know a few keywords to search as you try learn things. Emacs can be a daunting tool (I don’t even know most of it myself yet, honestly), but you can do the most critical things without too much difficulty and a bit of patience.