Skip to content

Instantly share code, notes, and snippets.

View jpmonettas's full-sized avatar

Juan Monetta jpmonettas

  • Montevideo, Uruguay
View GitHub Profile
@jpmonettas
jpmonettas / clj-find-class
Created November 16, 2020 14:33
Find classes in your clojure classpath
#!/bin/bash
SEARCH_TERM=$1;
for jar in $(clj -Spath | tr ":" "\n" | grep -E ".jar$"); do
jar -tf "$jar" | grep -i --color $SEARCH_TERM && echo "^----$jar \n";
done;
@jpmonettas
jpmonettas / lazy-primes.clj
Created July 25, 2018 22:51
Clojure lazy primes
;; Addapted from python generator found at https://zach.se/project-euler-solutions/10/#python
(defn lazy-primes
"A lazy sequence that yields prime numbers using Eratosthenes Sieve impl."
([] (lazy-primes 2 {}))
;; n is the number we are checking for primality
;; facts maps composite integers to primes
([n facts]
(if (not (contains? facts n))
(lazy-seq (cons n ;; yield since its not composite
@jpmonettas
jpmonettas / defit.el
Created July 12, 2018 14:11
Quickly define let bindings in Emacs Cider
(defun cider-binding-defit-init ()
(interactive)
(cider-nrepl-request:eval
"(in-ns 'defit)
(defn get-bindings [form]
(cond
(vector? form) (into () form)
(map? form) (into () (:keys form))
:else (list form)))"
(lambda (x) (message "DONE"))))
@jpmonettas
jpmonettas / tools.el
Created June 24, 2018 23:09
Quickly share a github link of what you are seeing in a buffer. Yanks a link you can paste in the browser.
(defun yank-github-link ()
"Quickly share a github link of what you are seeing in a buffer. Yanks
a link you can paste in the browser."
(interactive)
(let* ((remote (or (magit-get-push-remote) "origin"))
(url (magit-get "remote" remote "url"))
(project (if (string-prefix-p "git" url)
(substring url 15 -4) ;; git link
(substring url 19 -4))) ;; https link
(link (format "https://github.com/%s/blob/%s/%s#L%d"
@jpmonettas
jpmonettas / walletstats.cljs
Created May 19, 2018 18:01
Dirty Clojurescript script to retrieve ethereum wallets balances, for using with conky etc
#!/home/jmonetta/bin/lumo
(require '[clojure.string :as str])
(require '[goog.string.format])
(def http (js/require "http"))
(def addresses {"0xa662c033F936D0e950772aE3934D4f7EA5DCF934" "wage"
"0x07906afa8Af02c8739ef59999769533e2a07426A" "reimb"})
;; Etherscan APIkey