Skip to content

Instantly share code, notes, and snippets.

View ivarref's full-sized avatar

Ivar Refsdal ivarref

View GitHub Profile
@ivarref
ivarref / Dockerfile
Last active September 7, 2016 11:45
Allow Dockerfiles to be executed with the help of PHP
#!/usr/bin/php
#<?php echo "\010"; system("docker build --tag=meh .", $retval); if ($retval==0 && $argc == 2 && $argv[1] == "run") { system("docker run meh", $retval); } exit($retval); /*
# Pre-build: $ chmod +x ./Dockerfile
# To build: $ ./Dockerfile
# To build and run: $ ./Dockerfile run
FROM node:6
package no.nsd.programvareutvikling;
import org.apache.commons.fileupload.FileItemIterator;
import org.apache.commons.fileupload.FileItemStream;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.io.IOUtils;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
{:db/id #db/id [:db.part/user]
:db/ident :nil->retract
:db/fn #db/fn {:lang :clojure
:params [db m & opts]
:code (letfn [(remove-nil
[m]
(let [f (fn [[k v]] (when (not (nil? v)) [k v]))]
(clojure.walk/postwalk (fn [x] (if (map? x) (into {} (map f x)) x)) m)))
(empty-coll->nil
(ns ivarref.recurring-cup
(:require [tea-time.core :as tt]
[tea-time.virtual :as tv])
(:import (java.time ZonedDateTime ZoneId Instant DayOfWeek)
(java.time.format DateTimeFormatter)
(tea_time.core Task)))
;; Example of how to add scheduling of functions returning ZonedDateTime
;; and lazy sequences returning ZonedDateTime to aphyr/tea-time
(ns dato.demo
(:require [datomic.api :as d])) ; datomic version 0.9.6024
(def url "datomic:mem://test-db")
(def conn (do (d/delete-database url)
(d/create-database url)
(d/connect url)))
(def schema
(ns dato.tuples2
(:require [datomic.api :as d])) ; Datomic pro 0.9.6024
(def url "datomic:mem://test-db")
(def conn (do (d/delete-database url)
(d/create-database url)
(d/connect url)))
(def schema
@ivarref
ivarref / hello.clj
Last active June 30, 2020 12:57
pedestal async solution
(ns hello
(:require [io.pedestal.http :as http]
[io.pedestal.http.route :as route]
[clojure.core.async :as async]
[cheshire.core :as json]))
; deps.edn:
; {:paths ["src"]
; :deps {io.pedestal/pedestal.service {:mvn/version "0.5.8"}
; io.pedestal/pedestal.route {:mvn/version "0.5.8"}
(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
.#!/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

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)]