INSTALLATION
echo "gem 'machinist_blueprint_with_method',\
git: 'git://gist.github.com/6204150.git',\
group: 'test'" >> Gemfile
EXAMPLE OF USAGE
Overload your ORM safely or Black magic of metaprogramming | |
========================================================== | |
Introduction | |
------------ | |
Ruby provides the great set of metaprogramming features. | |
Metaprogramming is a bit like magic, which makes something astonishing possible. | |
But there are two kinds of magic: white magic, which does good things, and black magic, which can do nasty things. | |
And unfortunately sometimes it is so easy to fall into the dark side of metaprogramming. |
# Docs | |
http://redis.io | |
http://www.infoq.com/presentations/newport-evolving-key-value-programming-model | |
http://rediscookbook.org | |
http://www.paperplanes.de/2010/2/16/a_collection_of_redis_use_cases.html | |
http://thechangelog.com/post/2801342864/episode-0-4-5-redis-with-salvatore-sanfilippo | |
http://www.slideshare.net/pauldix/indexing-thousands-of-writes-per-second-with-redis | |
http://ai.mee.nu/is_couchdb_the_anti-redis | |
http://kkovacs.eu/cassandra-vs-mongodb-vs-couchdb-vs-redis | |
http://antirez.com/post/take-advantage-of-redis-adding-it-to-your-stack.html |
## | |
# If you encountered a problem like this: | |
# Errno::EMLINK: Too many links ...releases/20110811111351/public/document/file/51159 | |
# Most likely it is caused by the limitations of your Linux filesystem - | |
# a directory can only have a certain number of sub-directories. | |
# | |
# http://blog.zachwaugh.com/post/309921185/ext3-filesystem-sub-directory-limit | |
# | |
## |
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
## | |
# @example | |
# ruby -rubygems `__FILE__` `source_bucket_name` `target_bucket_name` | |
# | |
# @author @ipoval | |
# | |
# @see https://github.com/ipoval |
fibonacci = Enumerator.new do |yielder| | |
n1, n2 = 0, 1 | |
loop do | |
yielder.yield n1 | |
n1, n2 = n2, n1 + n2 | |
end | |
end | |
p fibonacci.first(20) |
$('#products').append('<%= j render(@products) %>'); | |
<% if @products.next_page %> | |
$('.pagination').replaceWith('<%= j will_paginate(@products) %>'); | |
<% else %> | |
$('.pagination').remove(); | |
<% end %> |
class Blog | |
attr_writer :post_source | |
def new_post | |
post_source.call.tap do |p| | |
p.blog = self | |
end | |
end | |
private |
# | |
find app/models/ -name "*.rb" | xargs grep -h --color -e ^class | cut -d ' ' -f 2 | sort | uniq | while read k; do echo model class: "$k"; grep -r -l -w -m 1 --color "$k" ./app ./config ./lib ./script --exclude-dir=*assets* | head -n 2 | wc -l | grep 1; done |
ruby -e " | |
'`find ./app/views -name _*`' | |
.split | |
.map { |f| f.split('/').last[1..-1][/[^\.]+/] } | |
.each { |f| system( %Q(fgrep -rq #{f} ./app/views/) ) ? nil : p(f) } | |
" |
INSTALLATION
echo "gem 'machinist_blueprint_with_method',\
git: 'git://gist.github.com/6204150.git',\
group: 'test'" >> Gemfile
EXAMPLE OF USAGE