Skip to content

Instantly share code, notes, and snippets.

View balinterdi's full-sized avatar
👌
Enjoying life, including work.

Balint Erdi balinterdi

👌
Enjoying life, including work.
View GitHub Profile
<script type="text/x-handlebars" data-template-name="ideas">
{{ render "ideas/new" }}
<div class="idea-list">
<ul class="unstyled">
{{#each controller}}
{{ render "idea" this }}
{{/each}}
</ul>
</div>
</script>
@balinterdi
balinterdi / artists.handlebars
Created November 29, 2013 16:47
The simplified artists template
<script type="text/x-handlebars" data-template-name="artists">
(...)
{{#each model}}
{{#link-to "artists.songs" this class="list-group-item artist-link"}}
{{name}}
(...)
{{/link-to}}
{{/each}}
(...)
</script>
@balinterdi
balinterdi / ideas-template.hbs
Last active December 29, 2015 01:49
A snippet from ideavote-emberfire
<script type="text/x-handlebars" data-template-name="ideas">
{{render "ideas/new"}}
<div class="idea-list">
<ul class="unstyled">
{{#each controller}}
{{render "idea" this}}
{{/each}}
</ul>
</div>
</script>
@balinterdi
balinterdi / html-helper.js
Last active December 21, 2015 04:09
Resources for the Ember.js workshop at Eurucamp 2013
Ember.Handlebars.helper('html', function(tweet, options) {
var replaceUrls = function(text, urlData) {
var start = urlData.indices[0];
var end = urlData.indices[1];
return text.slice(0, start) + '<a href="' + urlData.expanded_url + '">' + urlData.display_url + '</a>' + text.slice(end);
}
// Essentially there is no way to extract urls from RTs from the data Twitter provides
// so we might as well go simply matching urls in the text
var text = tweet.get('text').replace(/\n/g, '<br />');
@balinterdi
balinterdi / Makefile
Created April 3, 2013 20:00
Makefile generated by bcrypt-ruby when bundle installing. See https://github.com/codahale/bcrypt-ruby/issues/59
SHELL = /bin/sh
# V=0 quiet, V=1 verbose. other values don't work.
V = 0
Q1 = $(V:1=)
Q = $(Q1:0=@)
n=$(NULLCMD)
ECHO1 = $(V:1=@$n)
ECHO = $(ECHO1:0=@echo)
@balinterdi
balinterdi / controlGroup.handlebars
Created March 27, 2013 21:19
Example view with layout in ember.js
<label class="control-label">{{ view.label }}</label>
<div class="controls">
{{ yield }}
</div>
@balinterdi
balinterdi / gist:5213779
Last active December 15, 2015 06:09
Trying to find a way to resubmit a form with a model that has become invalid. The transaction cannot be reused and the dirty model cannot be moved to another transaction since it is dirty.
becameInvalid: ->
@get('transaction').remove(this)
transaction = App.store.transaction()
transaction.add(this) # => Uncaught Error: assertion failed: Once a record has changed, you cannot move it into a different transaction
(ns benchmark-assoc.core
(:require [criterium.core :as crit]))
(defn no-assoc [items]
(apply hash-map (vec (flatten items))))
(defn assoc-all [items]
(apply assoc {} (vec (flatten items))))
(defn assoc-each-one [items]
@balinterdi
balinterdi / group_by_reducers.clj
Created December 7, 2012 09:15
Implement group-by with reducers
(ns group-by-reducers.core
(:require [clojure.core.reducers :as r :only [fold reduce map]])
(:require [criterium.core :as c]))
(defn group-by-naive [f coll]
(reduce
(fn [groups a]
(assoc groups (f a) (conj (get groups a []) a)))
{}
coll))