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 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 |
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
| 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 |
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
| 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 |
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
| ## Example inspect result, stored as 'line' | |
| "max = 60\n" | |
| ## Test | |
| line.match(/.*(max|count|active|inactive|global queue).*[=:]\s+(\d+).*/) | |
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
| <% 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 %> |
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
| def profile_url | |
| Rails.application.routes.url_helpers.user_url(self, :host=>project.domain) | |
| end | |
| def as_json(options={}) | |
| super({ | |
| :only=>[:first_name, :last_name], | |
| :methods=>[:profile_url] | |
| }.merge(options)) | |
| 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
| require 'rubygems' | |
| require 'json' | |
| require 'benchmark' | |
| user = JSON.parse(<<EOS) | |
| { "person": { "id": "19198543@N06", "nsid": "19198543@N06", "ispro": 1, "iconserver": "3280", "iconfarm": 4, "path_alias": "hopskipandjump", "gender": "M", "ignored": 0, "contact": 0, "friend": 0, "family": 0, "revcontact": 0, "revfriend": 0, "revfamily": 0, | |
| "username": { "_content": "hopskipandjump" }, | |
| "location": { "_content": "" }, | |
| "timezone": { "label": "Central Time (US & Canada)", "offset": "-06:00" }, | |
| "description": { "_content": "Family" }, |
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
| def time_left(timestamp) | |
| diff = timestamp - Time.zone.now | |
| d = (diff / 86400).floor | |
| h = ((diff / 3600) % 24).floor | |
| m = ((diff / 60) % 60).round | |
| {:days=>d, :hours=>h, :minutes=>m} | |
| 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
| after "deploy:finalize_update", "deploy:assets:conditionally_precompile" | |
| namespace :deploy do | |
| namespace :assets do | |
| desc "Remove callback for asset precompiling unless assets were updated based on Git fetch/merge." | |
| task :conditionally_precompile, :roles => assets_role, :except => { :no_release => true } do | |
| updated_assets = capture("cd #{latest_release}; git diff --name-only #{old_commit} #{new_commit}", :except => { :no_release => true }).split.find_all{|fname| File.dirname(fname).match(/^(vendor|app|lib)\/assets/) } | |
| if(updated_assets.empty?) |
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
| set :max_asset_age, 2 ## Set asset age in minutes to test modified date against. | |
| after "deploy:finalize_update", "deploy:assets:determine_modified_assets", "deploy:assets:conditionally_precompile" | |
| namespace :deploy do | |
| namespace :assets do | |
| desc "Figure out modified assets." | |
| task :determine_modified_assets, :roles => assets_role, :except => { :no_release => true } do | |
| set :updated_assets, capture("find #{latest_release}/app/assets -type d -name .git -prune -o -mmin -#{max_asset_age} -type f -print", :except => { :no_release => true }).split |