This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns user | |
(:require [clojure.tools.namespace.repl :as ns-tools] | |
[clojure.string :as string] | |
[clojure.java.io :as io])) | |
(ns-tools/disable-reload!) | |
(let [reload-dirs (->> (or (try | |
(require 'boot.core) | |
((resolve 'boot.core/get-env) :directories) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Quoting symbols in collection before passing them to eval so that they are quoted when evaluated | |
(let [test #{'a 'b 'c}] `(println ~@(map #(eval `''~%) test))) | |
; => (clojure.core/println (quote a) (quote c) (quote b)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{:foreign-libs [{:file "cljsjs/common/pikaday.inc.js" | |
:provides ["org.pikaday"]} | |
{:file "cljsjs/common/pikaday.inc.js" | |
:requires ["org.moment"] | |
:provides ["org.pikaday.with-moment"]}] | |
:externs ["cljsjs/common/pikaday.ext.js"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns foobar.ui.view.profile ...) | |
(defmethod r/route-change :profile-view | |
[data] | |
(go | |
(let [resp (<! (http/get "/api/users/current" {:ref "nav"}))] | |
(swap! app/app assoc :profile (-> (:body resp) | |
(f/->form-state domain/User)))) | |
data)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Test | |
(time | |
(dotimes [i 10000] | |
(ac/highlight-string "foo bar hello world" ["oo" "ello"]))) | |
; First try | |
; Speed: ~1200ms | |
; Problems: only matches term once | |
(defn highlight-match |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Reagent & re-frame | |
(defn form-group | |
[form real-el | |
{:keys [ks input label] | |
:or {size 6} | |
:as opts}] | |
(let [error (reaction (get-in (::errors @form) ks))] | |
(fn [] | |
[:div.form-group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defapi app | |
(swagger-ui "/api-docs") | |
(swagger-docs) | |
(context "/js" [] | |
(middlewares [(caching/cache-middleware caching/cache-30d)] | |
(resources "" {:root "public/js"}))) | |
(context "/images" [] | |
(middlewares [(caching/cache-middleware caching/cache-30d)] | |
(resources "" {:root "public/images"}))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn zero-pad | |
([n] (if (<= 0 n 9) (str "0" n) (str n))) | |
([n pad] | |
(let [N (js/Math.pow 10 pad)] | |
(if (< n N) | |
(.slice (str (+ N n)) 1) | |
(str n))))) | |
; Formatter and regex could be generated maybe by using a macro | |
; Global def is undesired as that can'be optimized by GClosure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gcc -Wall -g -o fckxkb fckxkb.c -ludev | |
#include <libudev.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <locale.h> | |
#include <unistd.h> | |
#include <string.h> | |
int main (void) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn user-file-position | |
"Guesses the file position (basename and line number) that the user is | |
most likely to be interested in if a test fails." | |
[] | |
(nth (map #(list (.getFileName %) (.getLineNumber %)) | |
(.getStackTrace (Throwable.))) | |
; Magic number | |
3)) | |
(defmacro ^:private deprecate! [was is] |