Skip to content

Instantly share code, notes, and snippets.

View pyykkis's full-sized avatar

Jarno Keskikangas pyykkis

  • Subtle Insights Oy
  • Finland
View GitHub Profile
@pyykkis
pyykkis / rspec_intro.rb
Created August 31, 2011 03:57
Mock objects rspec style
-----------------
my_world.rb
class MyWorld
def initialize
@king = King.new
end
def king_of_the_world
@pyykkis
pyykkis / index.jade
Created September 4, 2011 14:10
Extremely simple js templates by convention: css class(+attribute) == json object field
div A single activity
ul.activity
li.date
li.activity
li.comment
li.user
div Multiple activities
table
tr
@pyykkis
pyykkis / kata-potter.clj
Created November 13, 2011 16:41
Clojure implementation for KataPotter
(def book-price 8)
(def discounts [1 1 0.95 0.90 0.80 0.75])
(defn price [books]
(let [uniques (set books)
discount (discounts (count uniques))]
(+ (* (count uniques) book-price discount))) (price (remove books uniques)))
@pyykkis
pyykkis / data.coffee
Created February 21, 2012 09:43
Transparency example: Nested lists with category titles
data = [
title: "Cat A"
items: [{name: "foo"},{name: "bar"}]
,
title: "Cat b"
items: [{name: "hello"}, {name: "world"}]
]
@pyykkis
pyykkis / basics.spec.coffee
Created May 11, 2012 12:31
Transparency tests refactored
it "should ignore null values", ->
doc = $ """
<div class="container">
<div class="hello"></div>
<div class="goodbye"></div>
</div>
"""
data =
hello: 'Hello'
@pyykkis
pyykkis / lists.spec.coffee
Created May 13, 2012 13:50
New syntax for plain value lists
# OLD SYNTAX
it "should render list containing simple values", ->
template = $ """
<div class="comments">
<span></span>
<label>blah</label>
</div>
"""
@pyykkis
pyykkis / curl.sh
Created September 2, 2012 15:54
Node.js httpServer middleware as it should be
curl localhost:3000
@pyykkis
pyykkis / jayq.js
Created October 14, 2012 17:45
jayq.core/text
ClojureScript:phonebook.core> text
#<function text($elem, txt) {
return $elem.text(txt)
}>
ClojureScript:phonebook.core> text2
#<function ($elem,txt){
switch(arguments.length){
case 1:
return text2__1.call(this,$elem);
Backbone.EventStream =
asEventStream: (eventName, eventTransformer = _.identity) ->
eventTarget = this
new Bacon.EventStream (sink) ->
handler = (args...) ->
reply = sink(new Bacon.Next(eventTransformer args...))
if reply == Bacon.noMore
unbind()
unbind = -> eventTarget.off(eventName, handler)
@pyykkis
pyykkis / example.coffee
Last active December 12, 2015 04:28
Function construction rules for Transparency directives.
template = $("""
<div>
<div class="name"></div>
<a class="url"></a>
</div>
""")
data =
name: 'Foo Bar'
url: 'linkedin.com/foo.bar'