Яuбy / Говнокод #18845 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
def show
    @favorite_venues = User.find(params[:id]).favorite_venues
    result = "["
    @favorite_venues.each do |i|
      result = result + "{'id':" + i.id.to_s + ", 'venue_id':{'id':" + i.venue_id.to_s + "}},"
    end
    result = result  + "]"
    render :json =>  result
  end

такое вот

DarkSun DarkSun, (Updated )

Комментарии (1, +1)

Яuбy / Говнокод #18832 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
class UserCategory < ActiveRecord::Base
   @@unique_id = 0
   ...
 
   def initialize
     @@unique_id += 1
   end

   def self.get_unique_id
    @@unique_id
  end

   def self.send_gcm_to_all(message)
    @@unique_id += 1
    ...
     User.all.each do |user|
       registration_ids = [user.gcm_id]
       options = { data: {id: self.get_unique_id, category: "all", message: "#{message}"}
       response = gcm.send(registration_ids, options)
   end
 
 end

DarkSun DarkSun, (Updated )

Комментарии (0)

Яuбy / Говнокод #18780 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
def perform
  ...
  settings = get_settings
  @browser = Selenium::WebDriver.for(settings.delete(:driver).try(:to_sym), settings)
  ...
end

def get_settings
  settings = Settings.get('selenium_terminal').map{ |(k, e)| k == 'desired_capabilities' && [k.to_sym, e.to_sym] || [k.to_sym, e] }
  Hash[settings] rescue nil
end

darkdemiurge darkdemiurge, (Updated )

Комментарии (1, +1)

Яuбy / Говнокод #18505 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
begin
      # Это пиздец
      artist_title = row.title.split(/ - /)
      if artist_title.length > 1
        row.artist = artist_title[0]
        row.title  = artist_title[1]
      else
        artist_title = row.title.split(/ — /)
        if artist_title.length > 1
          row.artist = artist_title[0]
          row.title  = artist_title[1]
        else
          artist_title = row.title.split(/ - /)
          if artist_title.length > 1
            row.artist = artist_title[0]
            row.title  = artist_title[1]
          else
            artist_title = row.title.split(/ – /)
            if artist_title.length > 1
              row.artist = artist_title[0]
              row.title  = artist_title[1]
            else
              artist = row.title.match(/\((.*?)\)/)
              artist = artist.captures[0]
              # puts artist_title
              # puts row.title
              # puts artist
              row.artist = artist
              row.title  = row.title.gsub('('+artist+')', '').strip
            end
          end
        end
      end
    rescue
      next
    end

gerasim13 gerasim13, (Updated )

Комментарии (44, +44)

Яuбy / Говнокод #18470 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
# Напишите псевдокод который инвертирует строки, например, "abc" -> "cba"

"abc".split("").reverse.join("").to_pseudocode

Вопрос в анкете на должность Ruby-программиста

zoer zoer, (Updated )

Комментарии (4, +4)