Skip to content

Instantly share code, notes, and snippets.

@geraldodev
geraldodev / deps.edn
Created October 31, 2023 07:44
deps.edn of the project that is experiencing parquet error
{:paths ["cloj/src"]
:deps
{
superstring/superstring {:mvn/version "3.2.0"}
techascent/tech.ml.dataset {:mvn/version "7.020"}
;; java dependencies
com.github.albfernandez/javadbf {:mvn/version "1.13.1"} ;; https://github.com/albfernandez/javadbf
org.apache.parquet/parquet-hadoop {:mvn/version "1.12.0"
:exclusions [org.slf4j/slf4j-log4j12]}
org.apache.hadoop/hadoop-common {:mvn/version "3.3.0"
(ns app.renderer.core
(:require
["@material-ui/core" :refer [AppBar Toolbar Badge Hidden IconButton]]
["@material-ui/core/Button" :default Button]
["@material-ui/core/styles" :refer [createMuiTheme makeStyles ThemeProvider]]
["react-dom" :as rdom]
[app.renderer.myhelix :refer [defnc]]
[helix.core :as hx :refer [$ <>]]
[helix.dom :as d]
))
(ns helix-ui.registry.default.example.progress-demo
(:require ["react" :as React]
[helix-ui.registry.default.ui.progress :refer [Progress]]
[helix.core :refer [$]]
[portfolio.react-18 :as portfolio :refer-macros [defscene]]))
(defscene ProgressDemo
:id
:helix-ui.portfolio.default.progress/demo
[]
(let [[progress setProgress] (.useState React 13)]
;; This code was adapted from com.teknql/shadow-cljs-tailwind-jit
(ns helix-ui.tailwind
(:require
[clojure.string]
[babashka.process :as proc]
[clojure.pprint :refer [pprint]]
[clojure.spec.alpha :as s]
)
(:import [java.nio.file Files]
[java.nio.file.attribute FileAttribute]))
@geraldodev
geraldodev / hooks_test.cljs
Created July 5, 2023 13:40
defscene with hooks to ilustrate the issue of not being able to use hooks inside defscene plainly, which has the outcome of the code not being captured for portfolio because we have to call a function
(ns hooks-test
(:require
["react" :as React]
[portfolio.react-18 :as portfolio :refer-macros [defscene]]
))
(defn ComponentExample
[props]
(let [^js [date _set-date] (React/useState (js/Date.))]
(React/createElement "div" nil (str date))))
@geraldodev
geraldodev / export-default-function.edn
Last active July 5, 2023 09:54
How would you map a default function component to clojurescript when generating equivalent code ?
{:type "File",
:errors [],
:program
{:type "Program",
:sourceType "module",
:interpreter nil,
:body
[{:type "ExportDefaultDeclaration",
:exportKind "value",
:declaration
(ns js-cljs.astutils-test
(:require
["./../../src/js_cljs/astutils" :refer [tagFunctionNodesAsReactComponent]]
["@babel/traverse$default" :as traverse]
[clojure.test :refer [deftest is testing]]
[js-cljs.core :refer [babel-parse]]
[applied-science.js-interop :as j]
))
(deftest react-function-tagging
@geraldodev
geraldodev / migrate.clj
Last active January 22, 2023 12:49
Babashka script to download and invoke the awesome MyBatis Migrations https://mybatis.org/migrations/index.html
#!/usr/bin/env bb
; migrate command, invoker of org.apache.ibatis.migration.Migrator
; Downloads maven artifact
; it adds --path=migrations if not specified as command-line-args
; this script is meant to be on root of the project, and when executed
; like ./migrate.clj it applies the migrations on the migrations subdirectory
; to initialize migrations path use:
; ./migrate.clj init
;
; After initializing the migrations subdirectory configure the credentials
@geraldodev
geraldodev / promises-cljs.md
Created August 16, 2022 09:39 — forked from pesterhazy/promises-cljs.md
Promises in ClojureScript

Chaining promises

Chaining promises in ClojureScript is best done using the thread-first macro, ->. Here's an example of using the fetch API:

(-> (js/fetch "/data")
    (.then (fn [r]
             (when-not (.-ok r)
               (throw (js/Error. "Could not fetch /data")))
             (.json r)))
@geraldodev
geraldodev / use_fetcher.cljs
Created July 9, 2022 01:35
react-router use-fetcher hook "beanified" use-fetcher hook that encaspulate keeps you from using useLoaderData just for getting the result of the router load function
(ns crudis.ui.hooks.use-fetcher
(:require
["react-router-dom" :refer [useLoaderData useFetcher]]
[cljs-bean.core :refer [bean]]
))
(defn use-fetcher
[]
(let [fetcher (useFetcher)
first-page (useLoaderData)