Skip to content

Instantly share code, notes, and snippets.

@flyingmachine
flyingmachine / 01-first-json-ld-example.json
Last active July 20, 2023 14:38
Code samples for Fluree's free introduction to JSON-LD workshop
{
"@context": {"s": "https://schema.org"},
"@type": "Cryptid",
"s:email": "freddy@flur.ee",
"s:jobTitle": "Research Assistant",
"s:name": "Freddy the Yeti"
}
;; useful for fixing linting errors
(map! :leader
(:prefix-map ("y" . "my shortcuts")
(:desc "flycheck list" "l" #'flycheck-list-errors)
(:desc "flycheck next" "j" #'flycheck-next-error)
(:desc "flycheck prev" "k" #'flycheck-previous-error)
(:desc "clj clean ns" "c" #'lsp-clojure-clean-ns)))
;; The question: how to clearly provide system def overrides?
;; There are two main scenarios where we want to do this:
;;
;; 1. Deriving a new "profile", e.g. deriving a test profile from a base profile
;; to be used for all tests
;; 2. Defining point overrides, e.g. you might want to mock out a specific component
;; only for a specific test
;;
;; Ultimately developers can use what works for them, but I want to figure out
;; the recommended approach. Also, I need to figure out the behavior of helpers

Keybase proof

I hereby claim:

  • I am flyingmachine on github.
  • I am nonrecursive (https://keybase.io/nonrecursive) on keybase.
  • I have a public key ASDS9szLnff6f8HuT0fd8PAIK9wAr_4J8_68dAGc2z50GQo

To claim this, I am signing this object:

@flyingmachine
flyingmachine / gist:4004807
Created November 2, 2012 22:41
clojure korma heroku db connection
(defdb db
(if (System/getenv "DATABASE_URL")
(let [db-uri (java.net.URI. (System/getenv "DATABASE_URL"))
user-and-password (clojure.string/split (.getUserInfo db-uri) #":")]
{:classname "org.postgresql.Driver"
:subprotocol "postgresql"
:user (get user-and-password 0)
:password (get user-and-password 1) ; may be nil
:subname (if (= -1 (.getPort db-uri))
(format "//%s%s" (.getHost db-uri) (.getPath db-uri))
(ns cljobs.resources.manage.os-projects
(:require [cljobs.resources.common :as c]
[cljobs.db.queries :as q]))
(def new-data (c/query-result q/user-os-projects))
(defn process-params
[ctx]
(-> (c/assoc-user ctx :os-project/user)
(update-in [:request :params]
(ns cljobs.resources.manage.os-projects
(:require [cljobs.resources.common :as c]
[cljobs.db.validations :as v]
[cljobs.db.queries :as q]
[datomic.api :as d]))
(def new-data (c/query-result q/user-os-projects))
(defn process-params
[ctx]
(div :class "filters"
(loop-tpl :bindings [name ["bob" "joe"]]
(div
(h3 (text "~{name}"))))
(ul
(loop-tpl :bindings [attr ["a" "b"]]
(li (text "~{attr}")))))
(div :class "filters"
(loop-tpl :bindings [name ["bob" "joe"]]
(div
(h3 (text "~{name}"))
(ul
(loop-tpl :bindings [attr ["a" "b"]]
(li (text "~{attr}")))))))
@flyingmachine
flyingmachine / defnpd.clj
Last active December 18, 2015 18:49
This macro lets you easily create functions with default positional arguments
(defmacro defnpd
;; defn with default positional arguments
[name args & body]
(let [unpack-defaults
(fn [args]
(let [[undefaulted defaulted] (split-with (comp not vector?) args)
argcount (count args)]
(loop [defaulted defaulted
argset {:argnames (into [] undefaulted)
:application (into [] (concat undefaulted (map second defaulted)))}