Skip to content

Instantly share code, notes, and snippets.

Ertuğrul Çetin ertugrulcetin

Block or report user

Report or block ertugrulcetin

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
@ertugrulcetin
ertugrulcetin / clojure-clojurescript-shadow-cljs-aws-elasticbeanstalk-circleci.md
Last active Oct 20, 2019
Clojure, ClojureScript and Shadow-cljs - Deploying to Elastic Beanstalk using CircleCi 2
View clojure-clojurescript-shadow-cljs-aws-elasticbeanstalk-circleci.md
@ertugrulcetin
ertugrulcetin / find-indexes.clj
Last active Aug 20, 2017
Finding indexes in nested data structure
View find-indexes.clj
(defn find-index-route
[x form]
(letfn [(get-nodes [form]
(tree-seq coll? identity form))
(get-tree [form]
(rest (get-nodes form)))
(get-level [form]
(if (or (not (coll? form)) (not (seq form)))
@ertugrulcetin
ertugrulcetin / smooth-scroll-clojurescript.cljs
Created May 26, 2017
Smooth scroll Clojurescript example
View smooth-scroll-clojurescript.cljs
(def speed 750)
(def moving-frequency 15)
(defn scroll-to-id
[elem target-id]
(let [target (.getElementById js/document target-id)
elem-scroll-top (-> elem .-scrollTop)
hop-count (/ speed moving-frequency)
gap (/ (- (-> target .-offsetTop) elem-scroll-top) hop-count)]
(doseq [i (range 1 (inc hop-count))]
@ertugrulcetin
ertugrulcetin / multi-comp.clj
Last active Apr 7, 2017
with multi-comp you can combine comp fns -> [:age :count :size :weight]
View multi-comp.clj
(def data [{:v 12, :a 10} {:v 21, :a 113} {:v 1, :a 2} {:v 12, :a 223} {:v 100, :a 23} {:v 1, :a 113}])
(defn multi-comp
([fns a b]
(multi-comp fns < a b))
([[f & others :as fns] order a b]
(if (seq fns)
(let [result (compare (f a) (f b))
f-result (if (= order >) (* -1 result) result)]
(if (= 0 f-result)
View if-let-multi-and-when-let-multi.clj
(defmacro assert-all
[& pairs]
`(do (when-not ~(first pairs)
(throw (IllegalArgumentException.
(str (first ~'&form) " requires " ~(second pairs) " in " ~'*ns* ":" (:line (meta ~'&form))))))
~(let [more (nnext pairs)]
(when more
(list* `assert-all more)))))
(defmacro when-let*
@ertugrulcetin
ertugrulcetin / 0_reuse_code.js
Last active Apr 22, 2016
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View if-let-multi.clj
(defmacro if-let*
([bindings then]
`(if-let* ~bindings ~then nil))
([bindings then else]
(if (seq bindings)
`(if-let [~(first bindings) ~(second bindings)]
(if-let* ~(drop 2 bindings) ~then ~else)
~(if-not (second bindings) else))
then)))
View when-let-multi.clj
(defmacro when-let*
([bindings & body]
(if (seq bindings)
`(when-let [~(first bindings) ~(second bindings)]
(when-let* ~(drop 2 bindings) ~@body))
`(do ~@body))))
@ertugrulcetin
ertugrulcetin / ColEx.clj
Created Feb 19, 2016
Clojure any? function
View ColEx.clj
(def any?
(complement not-any?))
You can’t perform that action at this time.