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
#! /usr/bin/env racket | |
; Euler problem #1. Sum of integers between 1 and N which are | |
; divisible by i, j, k, ..., or l. | |
; | |
; The sum 1+2+3+...+n = (n^2 + n)/2, call this sum-range(n). | |
; | |
; Then the sum of i+2i+3i+...+qi = i * sum-range(floor(n/i)), where | |
; qi is the greatest multiple of i such that i <= n. | |
; |
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
{:db/id #db/id[:db.part/db] | |
:db/doc "Works like clojure.core/swap!, basically." | |
:db/ident :swap! | |
:db/fn #db/fn {:lang "clojure" | |
:params [db id k expr args] | |
:code "(let [f (if-not (string? expr) | |
(resolve expr) | |
(eval (read-string expr))) | |
e (datomic.api/entity db id) | |
v (apply f (concat [(get e k 0)] args))] |
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
(def bgs | |
"List of tasks running in other threads that will need to be cleaned up before | |
boot can exit." | |
(atom ())) | |
;; cleanup background tasks on shutdown | |
(-> (Runtime/getRuntime) | |
(.addShutdownHook (Thread. #(doseq [job @bgs] (future-cancel job))))) | |
(deftask once |
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
(page "index.html" | |
(:refer-hoplon :exclude [form]) | |
(:require | |
[clojure.string :as string] | |
[tailrecursion.hoplon.reload :refer [reload-all]])) | |
;; auto-reload the page when you modify this file | |
(reload-all) | |
;; UTILITY FUNCTIONS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
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
I've been using the triple-backquote method and it works pretty well. For example: | |
``` | |
(map inc [1 2 3]) | |
``` | |
Check out [the source for this post](https://gist.github.com/micha/37b02eb356094f8611f9) on GitHub. |
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
(defmacro text= [form] | |
`(tailrecursion.javelin/cell= ~(interpol8 form))) |
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
(defmacro defbound [sym bindings] | |
`(defmacro ~sym [& body#] | |
`(let ~'~bindings ~@body#))) | |
(comment | |
user=> (defbound with-xy [x 100 y 200]) | |
#'user/with-xy | |
user=> (with-xy (+ x y)) | |
300 | |
) |
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
set nocompatible " be iMproved, required | |
filetype off " required | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" alternatively, pass a path where Vundle should install plugins | |
"call vundle#begin('~/some/path/here') | |
" let Vundle manage Vundle, required |
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
set nocompatible " be iMproved, required | |
filetype off " required | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" alternatively, pass a path where Vundle should install plugins | |
"call vundle#begin('~/some/path/here') | |
" let Vundle manage Vundle, required |
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
;; -*- mode: clojure; -*- | |
(set-env! | |
:src-paths #{"src/clj" "src/cljs"} | |
:rsc-paths #{"resources"} | |
:update :always | |
:dependencies '[[org.clojure/clojure "1.7.0-alpha4"] | |
[org.clojure/core.async "0.1.346.0-17112a-alpha"] | |
[com.taoensso/timbre "3.3.1-1cd4b70"] | |
[http-kit "2.1.19"] |
OlderNewer