Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrea Richiardi arichiardi

View GitHub Profile
@arichiardi
arichiardi / pom-deps-to-clj
Created Jun 3, 2019
Convert the output of mvn dependency:list to leiningen deps
View pom-deps-to-clj
#!/usr/bin/env bash
set -euo pipefail
# The following is the mvn dependency:list expected output
#
# [INFO] The following files have been resolved:
# [INFO] com.elasticpath.service.tenant:tenant-service-model:jar:1.0-SNAPSHOT:compile
# [INFO] com.elasticpath.service.tenant:tenant-service-dao:jar:1.0-SNAPSHOT:compile
@arichiardi
arichiardi / shadow-build.clj
Created Mar 20, 2019
Shadow-cljs cljs deps.edn hook
View shadow-build.clj
(ns user.shadow-build
(:require [cheshire.core :as json]
[clojure.java.io :as io]))
(def ^:private package-json-path "package.json")
(def ^:private deps-edn-path "src/deps.cljs")
(defn deps-cljs
[package-json-edn]
{:npm-deps (get package-json-edn "dependencies" {})})
@arichiardi
arichiardi / package
Last active Jun 19, 2018
This is an example of how to bundle a ClojureScript artifact with webpack on node
View package
#!/bin/bash
do_usage() {
echo
echo "Package the zip ready for lambda deployment."
echo
echo " -s is the stage, will default to dev is absent."
echo " -p accepts an dir path where the package will be copied, it defaults
to \"./.serverless\"".
echo " -B option skips compilation, in case you already have compiled
View lumo-proposal.md

lumo logo

Lumo Unbundled

This is a proposal for creating a new package along with lumo-cljs containing all the un-bundled JavaScript files needed for the current lumo to work, like:

  • target/bundle.min.js
  • target/main.js
  • target/main.js.map
@arichiardi
arichiardi / dump-npm-deps.sh
Created Mar 5, 2018
Dump the Clojure :npm-deps index
View dump-npm-deps.sh
clojure -e "(require '[cljs.closure :as cc] '[clojure.pprint :refer [pprint]]) (pprint (cc/index-node-modules-dir $(cat cljsc_opts.edn)))" > npm-deps.edn
@arichiardi
arichiardi / build.clj
Last active Nov 11, 2017
Data oriented defedntask for boot-clj, sample (macro not included)
View build.clj
(def env-web-prod {:resource-paths #{"resources"}
:source-paths #{"src/web" "src/shared"}
:dependencies '[[org.clojure/clojure "1.9.0-alpha14"]
[adzerk/boot-cljs "2.0.0-SNAPSHOT" :scope "test"]
[org.clojure/clojurescript "1.9.456" :scope "test"]
[org.clojure/test.check "0.9.0"] ;; AR - at the moment we need it, see http://dev.clojure.org/jira/browse/CLJS-1792
[adzerk/env "0.4.0"]
[binaryage/oops "0.5.2"]
[cljsjs/d3 "4.3.0-3"]
[cljsjs/intersections "1.0.0-0"]
View boot-shim.clj
(require 'clojure.repl)
;; macros
;; https://github.com/boot-clj/boot/commit/045d01101d61d947e1efd729e1f73b5690020928
(intern 'clojure.core (with-meta 'doc {:macro true}) @#'clojure.repl/doc)
(intern 'clojure.core (with-meta 'dir {:macro true}) @#'clojure.repl/dir)
(intern 'clojure.core (with-meta 'source {:macro true}) @#'clojure.repl/source)
;; fns
(intern 'clojure.core 'apropos @#'clojure.repl/apropos)
@arichiardi
arichiardi / email.clj
Created Jul 15, 2016
Send an email with attachments using SES, postal and selmer
View email.clj
ns services.email
(:require [clojure.tools.logging :as log]
[clojure.string :as string]
[clojure.java.io :as io]
[schema.core :as s]
[camel-snake-kebab.core :as csk]
[camel-snake-kebab.extras :as cske]
[amazonica.core :as aws]
[amazonica.aws.simpleemail :as ses]
[selmer.parser :as selmer]
@arichiardi
arichiardi / profile.boot
Last active Jul 6, 2016
Profile.boot for postgres in a docker
View profile.boot
(require '[boot.pod :as pod])
(def pod-deps '[[boot/core "2.6.0" :scope "test"]
[adzerk/env "0.3.0" :scope "test"]
[me.raynes/conch "0.8.0" :scope "test"]])
(deftask postgres
[t type VAL str "The build type as string"]
(let [pod (future (pod/make-pod (update-in (get-env) [:dependencies] into pod-deps)))]
(with-pass-thru _
@arichiardi
arichiardi / boot-rebase.clj
Last active Sep 29, 2016
Boot rebase task
View boot-rebase.clj
;; https://github.com/boot-clj/boot/pull/398
(defn filter-tmpfiles
"Filter TmpFiles that match (a least one in) metadata-preds.
Metadata-preds is a set of functions which will receive a TmpFile and
tried not in a specific order. If no predicate in the set returns
true-y, the file is filtered out from the returned TmpFiles.
If invert is specified, the behavior is reversed."
([tmpfiles metadata-preds]