Skip to content

Instantly share code, notes, and snippets.

View edtsech's full-sized avatar
🕵️‍♂️

Eduard Tsech edtsech

🕵️‍♂️
  • Prague, Czech Republic
View GitHub Profile
@edtsech
edtsech / lightning_talk_proposal.md
Last active January 31, 2023 07:29
Combining snapshot testing and component library -- ReactiveConf 2017 talk proposal

This is a proposal for a lightning talk at Reactive Conf. Please 🌟 this gist to push the proposal!

Combining snapshot testing and component library

Do you test presentational logic of your components? No? Yes, but you feel like you are writing a lot of dummy tests? You even probably use snapshot tests for that, but don't feel like you make enought value from them..

If so, click 🌟 button on that Gist!

I'll talk how our team is using snapshot testing to iterate faster,

rightCurry = function (f) {
let args = Array.prototype.slice.call(arguments).slice(1);
return function(firstArg) {
return f.apply(null, [firstArg].concat(args))
}
}
fullName = function (name, middleName, lastName) { return name + " " + middleName + " " + lastName }
// rightCurry(fullName, "David", "Doe")("John") -> "John David Doe"
@edtsech
edtsech / flipArgs.js
Last active November 7, 2016 18:44
A function which moves argument of passed function from the first position to the last position.
flipArgs = function (f) {
return function() {
let args = Array.prototype.slice.call(arguments);
return f.apply(null, args.slice(1).concat(args[0]))
}
}
fullName = function(name, lastName) { return name + ' ' + lastName}
// fullName("John", "Doe") -> "John Doe"
(defn split-by
"Create from sequence (l) sequence of sequences with specified number of elemenets (c)
Example:
(split-by 2 [1 2 3 4 5 6 7])
=> '((1 2) (3 4) (5 6) (7))"
[c l]
(if (seq l)
(cons (take c l) (split-by c (drop c l)))))
(defn split-into-chunks
@edtsech
edtsech / vali.clj
Last active December 17, 2015 23:59
Clojure Data Validator in 10 lines
(defn validate [data schema]
(into {} (for [[x y] schema]
[x (if (contains? data x)
(let [res (x data)]
(try (y res) (catch IllegalArgumentException e false)))
false)])))
(defn valid? [data schema]
(every? true? (vals (validate data schema))))
@edtsech
edtsech / merge.rb
Created December 23, 2012 18:07
Merge two hashes/dictionaries in Ruby and Python.
h1 = { "a" => 100, "b" => 200 }
h2 = { "b" => 254, "c" => 300 }
h3 = h1.merge(h2)
h3 #=> {"a"=>100, "b"=>254, "c"=>300}
h1 #=> { "a" => 100, "b" => 200 }
@edtsech
edtsech / compojure.clj
Last active December 10, 2015 01:34
Get Rails like controller syntax from Compojure DSL in 5 minutes with few very simple macros.
(defroutes posts-routes
(context "/posts" []
(GET "/" request ...)
(GET "/new" request ...)
(POST "/" request ...)))
@edtsech
edtsech / blog.clj
Created September 8, 2012 06:13
Enlive templating
(use 'net.cgrand.enlive-html)
; Define our posts, it can be response from the database.
(def posts [{:title "First post"
:content "Content of my first post."
:comments [{
:user "edtsech"
:text "boom"}
{:user "anonymous"
:text "blah-blah-blah"}]}
@edtsech
edtsech / 1000.rb
Created September 5, 2012 20:50
From 0 till 1000
THOUSAND = -> p { -> x { p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[
p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[
p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[
p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[
p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p
@edtsech
edtsech / boom.rb
Created July 30, 2012 11:49
Two classes with the same name, but with different obejct_id.
ContentFor = Class.new
x = ContentFor.new
puts x.class.object_id # => 2266662780
# puts x.class.name
ContentFor = Class.new
y = ContentFor.new
puts x.class.object_id # => 2266662780