Skip to content

Instantly share code, notes, and snippets.

@stelcodes
stelcodes / bb-postgresql-backup-restore.edn
Last active July 1, 2022 05:20
Babashka Tasks for PostgreSQL Backups
; run `bb backup` to backup database
; run `bb restore` to restore latest backup
{:min-bb-version "0.4.0",
:tasks {; CONSTANTS
db-name "dev_blog",
backup-dir "backups",
now (str (java.time.LocalDateTime/now)),
; TASKS
create-backup-dir {:depends [backup-dir], :task (babashka.fs/create-dirs backup-dir)},
@rksm
rksm / trace_cljs_repl_start.clj
Last active July 27, 2019 07:10
trace figwheel start
;; clj -R:figwheel -Sdeps '{:deps {org.clojure/tools.trace {:mvn/version "0.7.10"}}}' -i trace_cljs_repl_start.clj -m figwheel.main -b dev -r
(ns user)
(require '[clojure.tools.trace :as t])
(require 'cljs.main)
(require 'cljs.repl)
(require 'figwheel.main)
(require 'figwheel.repl)
(require 'figwheel.core)
@mfikes
mfikes / file_io.clj
Created September 9, 2018 15:28
Async file io in Clojure
(ns api-server.file-io
(:use [clojure.tools.logging :only (info warn error)])
(:import (java.nio.channels CompletionHandler AsynchronousFileChannel)
(java.nio ByteBuffer)
(java.nio.file.attribute FileAttribute)
(java.nio.file StandardOpenOption)
(java.util.concurrent Executors))
(:require [clojure.core.async :as async :refer [chan go put! close!]]
[clojure.java.io :as io]))
@mfikes
mfikes / README.md
Last active March 8, 2019 12:11
cljs.main rebel-readline

Start cljs.main with rebel-readline:

clojure -Sdeps '{:deps {github-mfikes/cljs-main-rebel-readline {:git/url "https://gist.github.com/mfikes/9f13a8e3766d51dcacd352ad9e7b3d1f" :sha "27b82ef4b86a70afdc1a2eea3f53ed1562575519"}}}' -i @setup.clj -m cljs.main

How Clojure's documentation can leapfrog other languages

Summary

I made a documentation generator that cashes in on Clojure's dynamism. See the play-cljs docs (a ClojureScript game library) for an example of its output.

The Problem

Like many of you, I've often wondered what my final regret will be on my deathbed. My best guess came to me in a dream recently. I was walking across the charred earth of an apocalyptic future world, maneuvering around the remains of the less fortunate. I was startled to find a young girl, barely holding onto her life. She murmured something to me. I asked her to repeat it, and she said more loudly: "I...wish your Clojure projects didn't have such crappy documentation."

@pesterhazy
pesterhazy / datomic-set-intersection.clj
Created January 3, 2017 11:35
Datomic set intersection query
(defn make-intersection-q
"Generate an intersection q for arbitrary sets of features"
[n]
(assert (pos? n))
{:find '[[?product-slug ...]]
:in ['$ (->> (range 1 (inc n)) (mapv #(symbol (str "?v" %))))]
:where
(into ['[?product :cat.product/slug ?product-slug]]
(map (fn [n]
['?product :cat.product/features (symbol (str "?v" n))])
@paultopia
paultopia / upload.cljs
Created December 21, 2016 21:50
clojurescript read uploaded text file in browser (derived from https://mrmcc3.github.io/post/csv-with-clojurescript/ )
(ns upload-file.core
(:require [reagent.core :refer [render atom]]
[cljs.core.async :refer [put! chan <! >!]])
(:require-macros [cljs.core.async.macros :refer [go go-loop]]))
;; derived from https://mrmcc3.github.io/post/csv-with-clojurescript/
;; and based on reagent-frontend template.
;; dependencies from project.clj in addition to clojure, clojurescript, and reagent:
;; [org.clojure/core.async "0.2.395"]
(set-env! :dependencies '[[clj-http "2.2.0"]])
(require '[clj-http.client :as http])
(def ^:private ^:const
retryable-http-status-codes
#{408; Request Timeout
409; Conflict
410; Gone
500; Internal Server Error
@iantruslove
iantruslove / Den-of-Clojure-intro-1-talk.md
Last active April 9, 2021 01:37
Den of Clojure - Intro to Clojure part 1

A gentle introduction to Clojure

Lisp Cycles (XKCD 297 / https://xkcd.com/297/)

Ian Truslove

Den of Clojure

2016-04-21


@Deraen
Deraen / 00_notes.md
Last active October 1, 2019 08:40
Compojure-api and Buddy
  • (:identity req) is auth backend independent way to access user data
  • login and logout implementation depends on auth backend
  • :current-user doesn't imply that authentication is required, route should also have :auth-rules if authentication is required