Skip to content

Instantly share code, notes, and snippets.

@WorldsEndless
WorldsEndless / error.java
Created June 27, 2019 23:01
The error message when attempting to evaluate a cljs buffer that has intra-project references in the ns
;; when attempting to load reformation.core-front https://github.com/WorldsEndless/reformation/blob/master/test/cljs/reformation/core_front.cljs
Show: Project-Only All
Hide: Clojure Java REPL Tooling Duplicates (11 frames hidden)
1. Unhandled clojure.lang.ExceptionInfo
reformation.status does not exist
#:cljs.repl{:error :invalid-ns}
repl.cljc: 204 cljs.repl$ns__GT_input/invokeStatic
repl.cljc: 199 cljs.repl$ns__GT_input/invoke
repl.cljc: 243 cljs.repl$load_namespace/invokeStatic
@WorldsEndless
WorldsEndless / routes.clj
Last active June 11, 2019 12:19
Reitit for auto-CRUD
;; CRUD routes are automatically generated for each of CREATE, READ, UPDATE, and DELETE fns
;; that exist (with those names) in the `humhelp.db.<table-name>` name-spaces. Note that READ
;; fns have multiple arities. With 0 args, they read all; with 1 arg, they read entry `id`
(ns humhelp.routes.admin
(:require [humhelp.layout :as layout]
[humhelp.middleware :as middleware]
[humhelp.db.user-groups :as user_groups]
[humhelp.db.attachments :as attachments]
[humhelp.db.categories :as categories]
@WorldsEndless
WorldsEndless / cljs-time problem
Created February 28, 2018 20:41
using cljs-time, my year seems bogus
isp.shared> d
#inst "2018-02-28T20:10:28.477-00:00"
isp.shared> (timef/unparse custom-formatter (timec/from-utc-time-zone d))
18-02-28 01:10 pm
isp.shared> (def custom-formatter (timef/formatter "Y-MM-dd hh:mm a"))
#'isp.shared/custom-formatter
isp.shared> (timef/unparse custom-formatter (timec/from-utc-time-zone d))
118-02-28 01:10 pm
isp.shared> (def custom-formatter (timef/formatter "YYYY-MM-dd hh:mm a"))
#'isp.shared/custom-formatter
@WorldsEndless
WorldsEndless / routes.cljs
Last active November 9, 2017 19:14
Routing, trying to move to Accountant from default Luminus
(ns isp.routes
(:require [reagent.core :as r]
[reagent.session :as session]
[secretary.core :as secretary :include-macros true]
[accountant.core :as accountant]
[goog.events :as events]
[goog.history.EventType :as HistoryEventType])
(:import goog.History))
@WorldsEndless
WorldsEndless / emacs-date-stamp.el
Created January 20, 2016 14:43
Insert date at point. With mods, insert hour/date/date+year.
(defun tsa/insert-current-time (&optional arg) (interactive "P")
(let ((command-options (cond
((equal arg '(16)) "date")
((equal arg '(4)) "date +%Y.%m.%d")
(t "date +%H:%M"))))
(insert (shell-command-to-string (concat "echo -n $(" command-options ")")))))
(global-set-key (kbd "C-c C-.") 'tsa/insert-current-time)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; USER DOCUMENT HANDLING ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn make-file-stream
"Takes an input stream--such as a MongoDBObject stream--
and produces a input-stream from it"
[file]
(piped-input-stream
(fn [output-stream]
(.writeTo file output-stream))))
@WorldsEndless
WorldsEndless / app_good.js
Created January 5, 2016 23:23
app.js as generated by lein figwheel, which works perfectly when swapped in to the program.
goog.addDependency("base.js", ['goog'], []);
goog.addDependency("../cljs/core.js", ['cljs.core'], ['goog.string', 'goog.object', 'goog.string.StringBuffer', 'goog.array']);
goog.addDependency("../ajax/protocols.js", ['ajax.protocols'], ['cljs.core']);
goog.addDependency("../ajax/xml_http_request.js", ['ajax.xml_http_request'], ['cljs.core', 'ajax.protocols']);
goog.addDependency("../com/cognitect/transit/util.js", ['com.cognitect.transit.util'], ['goog.object']);
goog.addDependency("../com/cognitect/transit/eq.js", ['com.cognitect.transit.eq'], ['com.cognitect.transit.util']);
goog.addDependency("../com/cognitect/transit/types.js", ['com.cognitect.transit.types'], ['com.cognitect.transit.util', 'com.cognitect.transit.eq', 'goog.math.Long']);
goog.addDependency("../com/cognitect/transit/delimiters.js", ['com.cognitect.transit.delimiters'], []);
goog.addDependency("../com/cognitect/transit/caching.js", ['com.cognitect.transit.caching'], ['com.cognitect.transit.delimiters']);
goog.addDependency("../com/cognitect
@WorldsEndless
WorldsEndless / app_bad.js
Last active January 5, 2016 23:21
The broken version of app.js, generated by lein uberjar
if(typeof Math.imul == "undefined" || (Math.imul(0xffffffff,5) == 0)) {
Math.imul = function (a, b) {
var ah = (a >>> 16) & 0xffff;
var al = a & 0xffff;
var bh = (b >>> 16) & 0xffff;
var bl = b & 0xffff;
// the shift by 0 fixes the sign on the high part
// the final |0 converts the unsigned value into a signed value
return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0)|0);
}
(def *data-skeleton* ; ct = cognitect.transit
(let [template-url "/data/template"
data (GET template-url {:headers {:Accept "application/transit+json"}}) ;; Is an object, not the desired Transit data (though the data shows up in my browser's inspector as the response)
transit-reader (do (.log js/console data) ; Object
(.log js/console (.getResponse data)) ; (an empty string)
(.log js/console (.getResponseBody data)) ; null
(.log js/console (.getResponseHeaders data)) ; Object { }
(.log js/console (.getResponseType data)) ; (an empty string)
(ct/reader :json))
converted (ct/read transit-reader data)] ; this fails: "unexpected character at line 1, char 2"
@WorldsEndless
WorldsEndless / first-gist.clj
Created October 14, 2015 15:26
My First Gist
(str "My first gist!")