Skip to content

Instantly share code, notes, and snippets.

View ivarref's full-sized avatar

Ivar Refsdal ivarref

View GitHub Profile
#!/usr/bin/env bb
(ns tray-tail
(:require [clojure.java.io :as io]
[clojure.string :as str]
[cheshire.core :as json]
[babashka.http-client :as http])
(:import (java.io File)
(java.net URLEncoder)
(java.time ZonedDateTime)
(java.time.format DateTimeFormatter)
@ivarref
ivarref / TrayMonitor.java
Created April 3, 2024 07:00
TrayMonitor.java
package no.nsd;
import java.awt.*;
import java.awt.event.*;
import java.io.IOException;
import java.net.ConnectException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
(ns user.db.transact-assert-basis-t
(:require [clojure.edn :as edn]
[clojure.stacktrace :as st]
[datomic.api :as d])
(:import (clojure.lang IBlockingDeref IDeref IPending)
(datomic Connection)
(java.util.concurrent Future TimeUnit TimeoutException)))
(def schema
"transact-assert-basis-t requires a single function present in the transactor: this function.
(ns com.github.ivarref.clj-paginate.ticker
(:require [clojure.string :as str])
(:import (clojure.lang IFn)
(java.lang AutoCloseable)))
(def is-cursive?
(try
(require '[cursive.repl.runtime])
true
(catch Exception _
(ns com.github.ivarref.cas-should-resolve-tempid-string
(:require [clojure.test :as test :refer [deftest is]]
[datomic.api :as d]))
(def ^:dynamic *conn* nil)
(def test-schema
[#:db{:ident :e/id, :cardinality :db.cardinality/one, :valueType :db.type/string :unique :db.unique/identity}
#:db{:ident :e/info, :cardinality :db.cardinality/one, :valueType :db.type/string}
#:db{:ident :e/version, :cardinality :db.cardinality/one, :valueType :db.type/long}])
(defn iterate-gql-connection [{:keys [api-url token]} query variables]
(->> (iteration
(fn [after]
(some->> (client/post api-url {:content-type :json
:accept :json
:as :json
:headers {"authorization" (str "Bearer " token)}
:form-params {:query query
:variables (merge variables {:after after})}})
:body
(ns datomic-oom
(:require [datomic.api :as d]
[clojure.set :as set])
(:import (java.util UUID)))
; This gist reproduces an odd (?) OutOfMemoryError with datomic-pro v1.0.6344
(def conn (let [uri "datomic:mem://demo"]
(d/delete-database uri)
(d/create-database uri)

This is on-prem. Both transactor and peer is running datomic pro v1.0.6344.

I am encountering a strange (?) OutOfMemoryError with the following simple query:

(d/query {:query {:find  '[(count ?tx) .]
                  :in    '[$ ?start ?end]
                  :where '[[?tx :tx/user-id _]
                           [?tx :db/txInstant ?inst]
                           [(.after ^java.util.Date ?inst ?start)]
.#!/bin/bash
rm client.crt client.pkcs8 2> /dev/null || true
rm server.crt server.pkcs8 2> /dev/null || true
rm -rf demoCA || true
mkdir -p demoCA/newcerts
touch demoCA/index.txt
set -ex
(defn ttl-fn
"Returns a function that will cache the `f` function.
The f function must return a map with two keys:
- :ttl number of seconds for the return value to live.
- :val the value that this function will return and cache."
[f]
(let [cache (atom nil)]
(fn [& args]
(locking cache