Skip to content

Instantly share code, notes, and snippets.


Denis Fuenzalida dfuenzalida

View GitHub Profile
dfuenzalida / repl.clj
Created Aug 4, 2020
ClojureScript defrecord and keyword lookups?
View repl.clj
(defrecord Attr [has-default default])
cljs.user=> (def attr (->Attr true 1))
cljs.user=> attr
#cljs.user.Attr{:has-default true, :default 1}
cljs.user=> (map? attr)
cljs.user=> (keys attr)
(:has-default :default)
View core.clj
(ns datomic-shortcut.core
(:require [datomic.api :as d]))
(def db-uri "datomic:mem://foo")
(d/create-database db-uri)
(def conn (d/connect db-uri))
dfuenzalida / funapp.clj
Created May 24, 2020
Sample run of funapp.clj - interop of Clojure and Python with libpython-clj
View funapp.clj
(ns appcompany.funapp
(:require [libpython-clj.python :as py :refer [py. py.- py.. py* py**]]
[libpython-clj.require :refer [require-python import-python]]))
(require-python '[builtins :as python])
(require-python '[base64 :as pybase64])
(require-python '[funniest :as pyfunniest])
dfuenzalida / demo.clj
Last active Mar 7, 2020
InputStream to Base64 stream
View demo.clj
;; An example InputStream made of 128 bytes:
(defn bytes-is []
( (into-array Byte/TYPE (range 128))))
(defn b64encode [s]
(String. (.encode (java.util.Base64/getEncoder) (.getBytes s))))
;; Now we read the input stream *in memory* (with slurp) and encode as base64:
(-> (bytes-is) slurp b64encode)
dfuenzalida / core.clj
Created Feb 7, 2020
Solución en Clojure al Desafío de la Gran Capicuá (
View core.clj
(ns grancapicua.core)
(defn reverso [res n]
(if (zero? n)
(recur (+ (* 10 res) (rem n 10)) (quot n 10))))
(defn capicua? [n]
(= n (reverso 0 n)))
dfuenzalida / part2.clj
Last active Jan 27, 2020
Solución Calculando Capicuas de en Clojure
View part2.clj
(ns capicuas.part2)
(defn reverso [res n]
(if (zero? n)
(recur (+' (* 10 res) (rem n 10)) (quot n 10))))
(defn not-palin? [n]
(not= n (reverso 0 n)))
dfuenzalida /
Last active Jan 20, 2020
Desafio Capicuas en Python3
def reverso(n):
res = 0
while (n > 0):
res = (res * 10) + (n % 10)
n = n//10
return res
def palin(n):
return n == reverso(n)
dfuenzalida / core.clj
Last active Jan 20, 2020
Desafio Capicuas de en Clojure
View core.clj
(ns capicuas.core)
(defn reverso [res n]
(if (zero? n)
(recur (+ (* 10 res) (rem n 10)) (quot n 10))))
(defn palin? [n]
(= n (reverso 0 n)))
dfuenzalida / compilation-output.txt
Created Jan 14, 2020
janet littleserver + json responses
View compilation-output.txt
denis@carbon:~/Projects/janet/littleserver$ janet -v
denis@carbon:~/Projects/janet/littleserver$ jpm --verbose build
generating executable c source...
found native /usr/local/lib/janet/
found native /usr/local/lib/janet/
compiling and linking build/lserve...
cc -std=c99 -Wall -Wextra -I/usr/local/include/janet -O2 -o build/lserve build/lserve.c /usr/local/lib/janet/circlet.a /usr/local/lib/janet/json.a /usr/local/bin/../lib/libjanet.a -lm -ldl -lrt -lpthread
/usr/local/lib/janet/json.a(json.static.o): In function `_janet_mod_config':
You can’t perform that action at this time.