Skip to content

Instantly share code, notes, and snippets.

philjackson / drag-drop-reagent.cljs
Created October 30, 2018 18:08
Drag and drop with Reagent and Interact.js
(defn draggable []
(let [pos (atom [0 0])]
#(let [[x y] @pos]
[:div.d {:style {:transform (str "translate(" x "px," y "px)")}}
"I can be dragged"])
(fn [this]
(defmacro evil-helper-cider-make-debug-command (&rest cider-commands)
"Make functions that wrap `cider-debug' commands.
Cider debug commands are sent through
`cider-debug-mode-send-reply'. ex. \(cider-debug-mode-send-reply
(let ((commands (if (consp cider-commands)
(list cider-commands))))
philjackson / compojure.clj
Last active July 27, 2023 13:17
Sensible compojure/ring defaults for an API
(ns my-api.handler
(:require [compojure.core :refer :all]
[ring.util.response :refer [response status content-type]]
[ring.middleware.params :refer [wrap-params]]
[ring.middleware.keyword-params :refer [wrap-keyword-params]]
[ring.middleware.json :refer [wrap-json-response wrap-json-body]]))
(defroutes app-routes
(context "/v1" []
(GET "/" req
(add-to-list 'package-archives '("marmalade" . ""))
(add-to-list 'package-archives '("melpa" . ""))
;; minimally, install use-package
(unless (package-installed-p 'use-package)
(package-install 'use-package))
(blink-cursor-mode -1)
(tool-bar-mode -1)
philjackson / attach.el
Last active August 30, 2021 19:13
From an mu4e view, without prompt, save all attachments to a directory and open dired.
(defvar bulk-saved-attachments-dir (expand-file-name "~/Documents/mu4e"))
(defun cleanse-subject (sub)
(downcase sub)))
(defmacro condev
"Takes clauses in the same style as `cond` but, if the left side is
truthy, will execute the right side of the expressions as a function
which gets the result of evaluation of the left side."
[& clauses]
(assert (even? (count clauses)))
(let [pstep (fn [[test step]] `(when-let [r# ~test] (~step r#)))]
`(list ~@(map pstep (partition 2 clauses)))))
philjackson / alarm.bash
Created September 1, 2015 11:21
Simple alarm for linux
#!/usr/bin/env bash
if [[ -z ${time} ]]; then
echo "Need a time to ring!" >&2
exit 1
echo "DISPLAY=:0 xmessage alarm" | at ${time}
function export-emacs {
if [ "$(emacsclient -e t)" != 't' ]; then
return 1
for name in "${@}"; do
value=$(eval echo \"\$${name}\")
emacsclient -e "(setenv \"${name}\" \"${value}\")" >/dev/null