Skip to content

Instantly share code, notes, and snippets.


Henrique Carvalho Alves hcarvalhoalves

View GitHub Profile
hcarvalhoalves / render.clj
Created Feb 3, 2021
sicmutils ->TeX w/ equate symbol
View render.clj
(ns render
(:require [clojure.string :as s]
[sicmutils.ratio :as r]
[sicmutils.expression.render :refer :all]))
(def ->TeX2
"Convert the given (simplified) expression to TeX format, as a string."
(let [TeX-accent (fn [accent]
(fn [[_ stem]]
(str "\\" accent " " (#'sicmutils.expression.render/maybe-brace (->TeX stem)))))
View pre-commit
# Add to project/.git/hooks/ w/ +x permission
echo "Running pre-commit linter..."
files=$(git diff --diff-filter=d --cached --name-only | grep -E '\.(base|clj)$' | tr '\n' ' ' | xargs)
lein do cljfmt fix $files, nsorg -e $files
if [ $? -ne 0 ]; then
View gist:498af57c462ea6d473c29c84d6821178
IDE: lsp-mode + clojure-lsp
REPL: cider
Static analysis: clj-kondo or joker
IDE: lsp-dart
hcarvalhoalves / poc.clj
Last active Jul 24, 2020
Calculating interest w/ linear algebra
View poc.clj
(ns poc
(:require [clojure.pprint]
[clojure.string :as str])
(:import (java.math RoundingMode MathContext)
(clojure.lang Ratio PersistentVector IPersistentCollection)))
(def ^:dynamic *precision* 10)
(def ^:dynamic *scale* 2)
(def ^:dynamic *rounding* RoundingMode/HALF_EVEN)
hcarvalhoalves /
Last active Apr 24, 2020
Download Free Springer Books
# Download TSV from
cat Free\ Springer\ Books\ -\ eBook\ list.tsv |
tail -n +1 |
cut -f 1,8 |
tr '\t' '\n' |
sed 's/^/"/;s/$/"/' |
xargs -n2 sh -c 'echo "url = \"$2.pdf\"\noutput = \"$1.pdf\""' sh
View gist:1291bfbb40ecf525184e24452ff18567
(ns logic.y
(:refer-clojure :exclude [== reify inc])
(:use [clojure.core.logic minikanren prelude
nonrel match]))
(defna findo [x l o]
([_ [[?y :- o] . _] _]
(project [x ?y] (== (= x ?y) true)))
([_ [_ . ?c] _] (findo x ?c o)))
hcarvalhoalves / type.scm
Created Feb 26, 2020
minikanren type inference
View type.scm
;;; WEB -- 18 June 2016
;; Type inferencer in miniKanren, adapted from Oleg's Kanren polymorphic type inferencer
;; Unlike the Kanren inferencer, this definition of !- is a pure
;; relation, with no cuts and no uses of project. This inferencer
;; also does not require a parser/unparser, and allows shadowing.
hcarvalhoalves /
Created Nov 24, 2019
Pandoc S3 Site Makefile
MARKDOWN = pandoc --standalone --from markdown+smart --to html --css theme.css
all: $(patsubst,%.html,$(wildcard *.md)) Makefile
rm -fv $(patsubst,%.html,$(wildcard *.md))
aws-3.7 s3 sync . s3:/<BUCKET> --exclude "*" --include "*.html" --include
View coercedate.scala
def coerceDate(dateFormat: String)(dateAsString: String) = {
val fmt = new java.text.SimpleDateFormat(dateFormat)
val dt = fmt.parse(dateAsString)
new java.sql.Date(dt.getYear, dt.getMonth, dt.getDay)
View circuit_breaker_pid.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.