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
(defn clob-to-string [clob] | |
"Turn an Oracle Clob into a String" | |
(with-open [rdr (java.io.BufferedReader. (.getCharacterStream clob))] | |
(apply str (line-seq rdr)))) | |
(with-connection mydb | |
(transaction | |
(with-query-results rs ["select documentation from station"] | |
; rs will be a sequence of maps, | |
; one for each record in the result set. |
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
(def ptrn | |
{ | |
:a {:pattern #"a(?!b)" | |
:purpose "Only allow a if it is not preceded by a 'b' (negative lookahead)" | |
:samples ["acdefg" ; ok | |
"abcdef" ; nil | |
]} | |
:b {:pattern #"(?i)(<title.*?>)(.+?)(</title>)" |
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 datascript-to-datomic-util | |
(:require [datascript :as d])) | |
;;;; a utility to help with a datomic-datascript roundtrip process involving: | |
;;; 1. export some data from a datomic database and transact into a datascript instance. | |
;;; 2. perform one or more transactions against datascript. | |
;;; 3. transact the sum of all changes made against datascript back into datomic in a single tx | |
;;; this namespace contains two public functions: | |
;;; listen-for-changes: listen to datascript transactions and build up a record of changes |
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
create table if not exists migrations ( | |
key text CONSTRAINT pkey PRIMARY KEY | |
); | |
create or replace function idempotent(migration_name text,code text) returns void as $$ | |
begin | |
if exists (select key from migrations where key=migration_name) then | |
raise notice 'Migration already applied: %', migration_name; | |
else | |
raise notice 'Running migration: %', migration_name; |
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.string :as s]) | |
(declare print-maze) | |
;; Maze GENERATION | |
(defn create-grid [rows cols] | |
(vec (repeat rows (vec (repeat cols #{}))))) | |
(defn north-of [[row col]] [(dec row) col]) | |
(defn south-of [[row col]] [(inc row) col]) |
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 my-shadow-app.dev-server | |
(:require [clj-http.client :as client] | |
[clojure.string :as string] | |
[shadow.http.push-state :as push-state]) | |
(:import [org.apache.http NoHttpResponseException])) | |
(defn handler | |
[{:keys [uri http-config body headers request-method] :as request}] | |
(if-not (string/starts-with? uri "/api") | |
(push-state/handle request) |
- High level overview https://yogthos.github.io/ClojureDistilled.html
- An Animated Introduction to Clojure https://markm208.github.io/cljbook/
- Interactive tutorial in a browser https://tryclojure.org/
- Interactive exercises http://clojurescriptkoans.com/
- Clerk notebooks with introductory examples https://github.clerk.garden/anthonygalea/notes-on-clojure
- More interactive exercises https://4clojure.oxal.org/
- Lambda Island tutorials https://lambdaisland.com/
- Functional Programming with Clojure resources https://practicalli.github.io/
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
package main.resources | |
//The global script scope | |
def ctx = context(scope: scriptScope()) | |
//What things can be on the script scope | |
contributor(ctx) { | |
method(name: 'pipeline', type: 'Object', params: [body: Closure]) | |
property(name: 'params', type: 'org.jenkinsci.plugins.workflow.cps.ParamsVariable') | |
property(name: 'env', type: 'org.jenkinsci.plugins.workflow.cps.EnvActionImpl.Binder') |
OlderNewer