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
[: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
`(let ~(vec (mapcat #(list % `('~ctx '~%)) (keys ctx)))
(defn contextual-eval ;; alternative
[ctx expr]
`(let ~(vec (apply concat ctx))
View cleanup.clj
(defn clean-up [m]
(reduce f {} m))
(defn f
[m [key value]]
(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))
(save-buffer args))
(global-set-key "\C-x\C-s" 'my-save-buffer)
View full_screen.el
;;toggle full-screen
(defun toggle-fullscreen ()
(if (frame-parameter nil 'fullscreen)
View cross_product.clj
(->> colls
(reduce #(for [x %1 y %2] [x y]))
(map flatten)))
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)
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")
View project_euler_problem_22.clj
(use '[ :only (reader read-lines)])
(def letter->index
{\A 1
\B 2
\C 3
\D 4
\E 5
\F 6
\G 7
(define (segments->painter segment-list)
(lambda (frame)
(lambda (segment)
((frame-coord-map frame) (start-segment segment))
((frame-coord-map frame) (end-segment segment))))
You can’t perform that action at this time.