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 create-project | |
[] | |
(sql/create-table | |
:project | |
[:id :int "PRIMARY KEY" "NOT NULL"] | |
[:name "varchar(30)" "NOT NULL"] | |
[:description :text "NOT NULL"])) |
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 contextual-eval [ctx expr] ;; from Joy of clojure | |
(eval | |
`(let ~(vec (mapcat #(list % `('~ctx '~%)) (keys ctx))) | |
~expr))) | |
(defn contextual-eval ;; alternative | |
[ctx expr] | |
(eval | |
`(let ~(vec (apply concat ctx)) |
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 clean-up [m] | |
(reduce f {} m)) | |
(defn f | |
[m [key value]] | |
(cond | |
(vector? value) (apply conj m (map clean-up value)) | |
(map? value) (conj m value) | |
:else (assoc m key value))) |
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
(defun my-save-buffer (&optional args) | |
"removing trailing whitespaces and tabs while saving buffer" | |
(interactive "p") | |
(untabify (point-min) (point-max)) | |
(whitespace-cleanup) | |
(save-buffer args)) | |
(global-set-key "\C-x\C-s" 'my-save-buffer) |
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
;;toggle full-screen | |
(defun toggle-fullscreen () | |
(interactive) | |
(set-frame-parameter | |
nil | |
'fullscreen | |
(if (frame-parameter nil 'fullscreen) | |
nil | |
'fullboth))) |
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
(->> colls | |
(reduce #(for [x %1 y %2] [x y])) | |
(map flatten))) |
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 amicable? [a] | |
(if (@amicable-nos a) true | |
(let [b (d a) | |
db (d b)] | |
(if (and (not= a b) (= a db)) | |
(do (swap! amicable-nos assoc b true) true) | |
false)))) |
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 number->wrd-cnt | |
{1 (count "one") | |
2 (count "two") | |
3 (count "three") | |
4 (count "four") | |
5 (count "five") | |
6 (count "six") | |
7 (count "seven") | |
8 (count "eight") | |
9 (count "nine") |
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
(use '[clojure.contrib.duck-streams :only (reader read-lines)]) | |
(def letter->index | |
{\A 1 | |
\B 2 | |
\C 3 | |
\D 4 | |
\E 5 | |
\F 6 | |
\G 7 |
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
(define (segments->painter segment-list) | |
(lambda (frame) | |
(for-each | |
(lambda (segment) | |
(draw-line | |
((frame-coord-map frame) (start-segment segment)) | |
((frame-coord-map frame) (end-segment segment)))) | |
segment-list))) |
OlderNewer