Skip to content

Instantly share code, notes, and snippets.

View mrpunkin's full-sized avatar

Bryan Corey mrpunkin

View GitHub Profile
<% cache(["categories", "index", "project", @project.id], :expires_in=>1.hour) do %>
<ul id="category_list" class="challenges columned clearfix">
<% @categories.each do |c| %>
<li class="grid_4"><a href="<%= category_path(c) %>">
<% if p = c.lead_photo_for(@project) %>
<div class="image" style="background: url(<%= p.square_src(220) %>) center center no-repeat;"><!-- <%= p.byline %> --></div>
<% end %>
<div class="info"><h3><%= c.name %></h3></div>
</a></li>
<% end %>
## Example inspect result, stored as 'line'
"max = 60\n"
## Test
line.match(/.*(max|count|active|inactive|global queue).*[=:]\s+(\d+).*/)
Tempfile.open(filename) do |t|
begin
t.binmode
t.write Net::HTTP.start(host){|http| http.get(url)}.body
FileUtils.cp(t.path, filepath)
ensure
t.close!
end
end
SELECT groups.id, groups.created_at AS group_created, MAX(gu.created_at) AS newest_user, MAX(gp.created_at) AS newest_photo, GREATEST(groups.created_at, IFNULL(MAX(gu.created_at), 0), IFNULL(MAX(gp.created_at), 0)) AS latest_activity FROM groups
LEFT OUTER JOIN groups_users gu ON groups.id = gu.group_id
LEFT OUTER JOIN group_photos gp ON groups.id = gp.group_id
GROUP BY groups.id
class Comment < ActiveRecord::Base
has_one :photo_invite
has_one :critique
def attachment
if photo_invite and photo_invite.invited_to
photo_invite
elsif critique then critique
else nil
end
Sass.compile(render :template=>'../assets/stylesheets/theme.css.scss').html_safe
resources :photos
## Results in standard restful routes, including
## photo GET /photos/:id(.:format) photos#show
match '/photos/:id(/in/:collection)' => 'photos#show', :via=>:get, :as=>'photo'
## Overrides old photo_path with
## photo GET /photos/:id(/in/:collection)(.:format) photos#show
/photos/:id/in/:collection_with_delim
## /photos/123/in/category-landscapes
/photos/:id/in/:collection/:collection_id
## /photos/123/in/category/landscapes
module MobileApi
def self.included(base)
base.extend ClassMethods
end
class ClassMethods
def mobile_api(*args)
opts = args.extract_options!
self.class_eval do
collection @photos
extends 'photos/show'
node(:src){|photo| photo.src(:thumb) }