Skip to content

Instantly share code, notes, and snippets.

Ratandeep Ratti rdsr

Block or report user

Report or block rdsr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View text data type not working
(defn create-project
[]
(sql/create-table
:project
[:id :int "PRIMARY KEY" "NOT NULL"]
[:name "varchar(30)" "NOT NULL"]
[:description :text "NOT NULL"]))
View contextual_eval.clj
(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))
View cleanup.clj
(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)))
View save_buffer.el
(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)
View cross_product.clj
(->> colls
(reduce #(for [x %1 y %2] [x y]))
(map flatten)))
View project_euler_problem_22.clj
(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
View strange_pattern.ss
(325 (10 15) (6 17) (1 18)) ;; 325 = 10^2 + 15^ = 6^2 + 17^2 = 1^2 + 18^2
(425 (13 16) (8 19) (5 20))
(650 (17 19) (11 23) (5 25))
;; ...
;; ...
;; ...
(5050 (45 55) (17 69) (3 71))
(5125 (47 54) (34 63) (30 65))
View full_screen.el
;;toggle full-screen
(defun toggle-fullscreen ()
(interactive)
(set-frame-parameter
nil
'fullscreen
(if (frame-parameter nil 'fullscreen)
nil
'fullboth)))
View pe_problem_21_fragment1.clj
(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))))
View project_euler_problem_17.clj
(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")
You can’t perform that action at this time.