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 detail | |
| return unless check_format | |
| @request = request | |
| @version = params[:version] | |
| @cycle = params[:cycle].to_i | |
| raise ActiveRecord::RecordNotFound if @cycle < 2000 | |
| @format = params[:format] | |
| @base_uri = base_uri(@request, @cycle, @version) | |
| @fec_candidate = FecCandidate.find_with_cycle_and_committee(@cycle.to_i,params[:id]) | |
| if not @fec_candidate |
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
| > var map = function() { emit(this._id, { new_message_count : this.new_message_count }); }; | |
| > var reduce = function(key, values) { | |
| ... var new_message_sum = 0; | |
| ... values.forEach(function(doc) { | |
| ... new_message_sum += doc.new_message_count | |
| ... }); | |
| ... return { stats: { new_message_count: new_message_sum } }; | |
| ... }; | |
| > var op = db.mail_reader_stats.mapReduce(map, reduce); |
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 attributes_for_indexing | |
| attributes.reject{ |key, value| ['_id', 'created_at', 'email', 'name', 'project_id', 'tags', 'updated_at'].include?(key) } | |
| end | |
| Sunspot.setup(Submission) do | |
| text :name, :boost => 2.0 | |
| text :email, :boost => 2.0 | |
| text :project_id, :boost => 2.0 | |
| date :created_at | |
| date :updated_at |
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 'w2tags' | |
| require File.join(File.dirname(__FILE__), '..', 'config', 'environment') | |
| W2 = W2Tags::Parser.new('rails') | |
| templates = Dir.glob("#{RAILS_ROOT}/app/views/**/*.haml") | |
| puts "converting #{templates.size} to erb :(" | |
| templates.each do |template| | |
| haml_data = File.read(template) | |
| erb = W2.parse_line("%initialize\n"<<haml_data).join |
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
| $(document).ready(function() { | |
| $('.async').live('click', function() { | |
| var current = $(this).text(); | |
| if ( current == 'show' ) { | |
| $(this).text('hide'); | |
| } else if (current == 'hide') { | |
| $(this).text('show'); | |
| } | |
| $.getJSON($(this).attr('href'), |
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 users(*ids_or_usernames) | |
| ids, usernames = [], [] | |
| ids_or_usernames.each do |id_or_username| | |
| if id_or_username.is_a?(Integer) | |
| ids << id_or_username | |
| elsif id_or_username.is_a?(String) | |
| usernames << id_or_username | |
| end | |
| end | |
| query = {} |
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
| irb(main):014:0> Submission.for_project("gulf-oil-spill").pending.to_json | |
| ActiveSupport::JSON::Encoding::CircularReferenceError: object references itself | |
| from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.0.beta4/lib/active_support/json/encoding.rb:59:in `check_for_circular_references' | |
| from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.0.beta4/lib/active_support/json/encoding.rb:47:in `encode' | |
| from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.0.beta4/lib/active_support/json/encoding.rb:222:in `encode_json' | |
| from (irb):14:in `map' | |
| from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.0.beta4/lib/active_support/json/encoding.rb:222:in `each' | |
| from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.0.beta4/lib/active_support/json/encoding.rb:222:in `map' | |
| from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.0.beta4/lib/active_support/json/encoding.rb:222:in `encode_json' | |
| from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.0.beta4/lib/active_support/json/encoding.rb:48:in `enc |
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
| x = 0 | |
| while x <= 10 | |
| y = 0 | |
| while y <= 10 | |
| puts "#{x},#{y}" | |
| y += 1 | |
| end | |
| x += 1 | |
| 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
| >> a = Attachment.new(:remote_image_url => url) | |
| Errno::ECONNRESET: Connection reset by peer | |
| from /usr/local/lib/ruby/1.8/net/protocol.rb:135:in `sysread' | |
| from /usr/local/lib/ruby/1.8/net/protocol.rb:135:in `rbuf_fill' | |
| from /usr/local/lib/ruby/1.8/timeout.rb:62:in `timeout' | |
| from /usr/local/lib/ruby/1.8/timeout.rb:93:in `timeout' | |
| from /usr/local/lib/ruby/1.8/net/protocol.rb:134:in `rbuf_fill' | |
| from /usr/local/lib/ruby/1.8/net/protocol.rb:116:in `readuntil' | |
| from /usr/local/lib/ruby/1.8/net/protocol.rb:126:in `readline' | |
| from /usr/local/lib/ruby/1.8/net/http.rb:2020:in `read_status_line' |