This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ 'world' | prepend:'hello' | upcase }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template = "{{foo}}" | |
Liquid::Template.parse(template).render({'foo' => 'bar'}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% rss source: http://rubysource.com/feed/%} | |
<article class='main rss_list'> | |
<h1>{{ feed.title }}</h1> | |
{% for item in feed.items limit:3%} | |
<section> | |
<h1><a href='{{item.link}}'>{{item.title}}</a></h1> | |
<p>{{item.description}}</p> | |
</section> | |
<hr/> | |
{%endfor%} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RenderRSS < Liquid::Block | |
def initialize(tag_name, markup, tokens) | |
super | |
@markup = markup | |
@attributes = {} | |
markup.scan(Liquid::TagAttributes) do |key, value| | |
@attributes[key] = value | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PostsController < ActionController::Base | |
after_filter :set_http_cache, :only => :index | |
private | |
def set_http_cache | |
expires_in(30.seconds, :public => true) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
end | |
class UsersController < ApplicationController | |
def update | |
User.find(params[:id]).update_attributes(params[:user]) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This gets X users within a distance of '10' radians | |
user = User.find_me_a_bloody_user | |
result = ActiveRecord::Base.connection.execute(" | |
SELECT | |
((ACOS( SIN( #{user.lat} * PI( ) /180 ) * SIN( latitude * PI( ) /180 ) + COS( #{user.lat} * PI( ) /180 ) * COS( latitude * PI( ) /180 ) * COS( ( | |
#{user.lng} - longitude) * PI( ) /180 ) ) *180 / PI( ) ) *60 * 1.1515) |
NewerOlder