we use the ro gem
a-2:~/git/dojo4/www $ ls public/ro/
chiclets pages people posts
# = YERB | |
# | |
# Who needs HAML when you have YAML + ERB? ;) | |
# | |
# See example.yaml below for an example. You can run this code | |
# by cloning this gist and then `ruby _yerb.rb example.yaml`. | |
# | |
# Notice that you need Ruby 1.9 so the hash order is preserved. | |
# Obviously, this is just for fun. Definitely slow as hell. | |
# |
we use the ro gem
a-2:~/git/dojo4/www $ ls public/ro/
chiclets pages people posts
(function($){ | |
$('.pagination a[data-remote=true]').live('ajax:success', function(e){ window.history.pushState('', '', $(e.target).attr('href')) }) | |
$(window).bind('popstate', function(){ $.ajax({url:window.location, dataType:'script'}) ; return true }); | |
})(jQuery); |
class Maybe | |
include Enumerable | |
def initialize(value) | |
@value = value | |
end | |
def each | |
yield value unless value.nil? | |
end |
(def ^:private gc-sm-cache! | |
"Maintains maximum cache size by intelligently pruning less valuable items." | |
(let [gc-running? (atom false)] | |
(fn [cache ttl max-items now] | |
(when-not @gc-running? | |
(reset! gc-running? true) | |
(let [snapshot @cache |
- flashes = {:notice => 'success', :alert => 'standard', :error => 'alert', :secondary => 'secondary'} | |
- flashes.each do |key, value| | |
- if flash[key] | |
.alert-box{:class => value, :data => { :alert => '' } } | |
= flash[key] | |
= link_to '×'.html_safe, '#', :class => 'close' |
var CourseApp = { | |
students: [], | |
courses: [], | |
teachers: [], | |
render_item: function(item, type) { | |
var html = this.render_html(item, type); | |
document.getElementById(type + "-list").innerHTML += html; | |
}, | |
render_items: function(items_name) { | |
var items = this[items_name]; |
##Running a Gem from Source
In your Gemfile, specify the gem and the path to its source.
gem 'gem_name', path: '/~/code/gem_folder'
Require the gem in your program.
def values(hsh, key) | |
return [] if !hsh.kind_of? Hash | |
v = hsh[key] ? [hsh[key]] : [] | |
hsh.values.select{|i| i.kind_of? Hash or i.kind_of? Array}.each do |val| | |
if val.kind_of? Hash | |
v+= values(val, key) | |
else | |
val.each {|i| v+= values(i, key)} | |
end | |
end |