This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foo=> (defmacro export [& var-names] | |
(let [var-names (set var-names)] | |
(doseq [[k v] (ns-publics *ns*)] | |
(when-not (contains? var-names k) | |
(alter-meta! v assoc :private true))))) | |
#'foo/export | |
foo=> (defn foo []) | |
#'foo/foo | |
foo=> (defn bar []) | |
#'foo/bar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '["vscode" :as vscode] | |
'[clojure.string :as str]) | |
(defn insert-num | |
[] | |
(let [editor vscode/window.activeTextEditor | |
position (.-active (.-selection editor)) | |
doc (.-document editor) | |
line (-> (.lineAt doc position) (.-text)) | |
character (last (str/trim line)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The module 'vscode' contains the VS Code extensibility API | |
// Import the module and reference it with the alias vscode in your code below | |
const vscode = require('vscode'); | |
const path = require('path'); | |
// this method is called when your extension is activated | |
// your extension is activated the very first time the command is executed | |
/** | |
* @param {vscode.ExtensionContext} context |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[promesa.core :as p] | |
'[reagent.ratom :as ratom]) | |
(def app-state (ratom/atom {:state-var-1 {:var-a 2 | |
:var-b 3} | |
:state-var-2 {:var-a 7 | |
:var-b 9}})) | |
(def app-var2a-reaction (ratom/make-reaction | |
#(get-in @app-state [:state-var-2 :var-a]))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[clojure.java.io :as io] | |
'[clojure.string :as str]) | |
(defn class->package | |
"Implementation by Marco Marini." | |
[class-file] | |
(with-open [dis (java.io.DataInputStream. (io/input-stream class-file))] | |
;; skip first 8 bytes | |
(.skipBytes dis 8) | |
(let [constant-pool-count (.readUnsignedShort dis) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# command line to deploy the project | |
gcloud functions deploy hello --runtime nodejs14 --trigger-http |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[babashka.fs :as fs]) | |
(let [counter (volatile! 0)] | |
(fs/walk-file-tree "." {:pre-visit-dir (fn [d _] | |
(if (= ".git" (fs/file-name d)) | |
(do (vswap! counter inc ) | |
:skip-subtree) | |
:continue))}) | |
@counter) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ $GRAALVM_HOME/bin/node --jvm --polyglot --vm.cp=$(clojure -Spath) $(which nbb) | |
user=> (.-version js/process) | |
"v14.18.1" | |
user=> (require '["path" :as path]) | |
nil | |
user=> (path/resolve ".") | |
"/Users/borkdude" | |
user=> (def Clojure (js/Java.type "clojure.java.api.Clojure")) | |
#'user/Clojure | |
user=> (def clj:require (.var Clojure "clojure.core" "require")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns dev.docgen | |
(:require [clojure.pprint :refer [pprint]] | |
[rewrite-clj.zip :as z] | |
[clojure.string :as str] | |
[clojure.java.io :as io]) | |
(:import (java.io File))) | |
(defn -form->markdown | |
"Clojure forms are evaluated and the result is automatically inserted in the generated markdown. | |
There is a special handling for 'def, we show their var binding instead" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns guestbook | |
(:require [cheshire.core :as cheshire] | |
[hiccup2.core :as hiccup] | |
[clojure.string :as str])) | |
(require '[babashka.pods :as pods]) | |
(pods/load-pod "./pod-babashka-postgresql") | |
(def db {:dbtype "postgresql" | |
:user "guestbook" |