1. C++ / Говнокод #16993

    +42

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    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
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    class Message {
    public:
        explicit Message(Level level);
        ~Message();
    
        Level level() const { return level_; }
        const time_t& time() const { return time_; }
        std::string text() const { return s_.str(); }
        bool enabled() const { return enabled_; }
    
        template<class T>
        Message& operator << (const T& t)
        {
            if (enabled_)
                s_ << t;
            return *this;
        }                                                                                       
    
        Message(Message& msg) { moveFrom(msg); }
        Message& operator = (Message& msg) { moveFrom(msg); return *this; }
        struct Ref {
            explicit Ref(Message& msg): msg_(&msg) {}
            Message* msg_;
        };                                                                                                                                
        operator Ref() { return Ref(*this); }
        Message(Ref r) { moveFrom(*r.msg_); }
        Message& operator = (Ref r) { moveFrom(*r.msg_); return *this; }
    
    private:
        Level level_;
        time_t time_;
        std::ostringstream s_;
        bool enabled_;
    
        void moveFrom(Message& msg)
        {
            level_ = msg.level_;
            time_ = msg.time_;
            s_.str(msg.s_.str());
            enabled_ = msg.enabled_;
            msg.enabled_ = false;
        }
    };

    move головного мозга

    roman-kashitsyn, 30 Октября 2014

    Комментарии (13)
  2. PHP / Говнокод #16992

    +156

    1. 1
    2. 2
    if($GLOBALS["curLogin"]!='sasha'){ echo '<div class="alert alert-error" style="margin:5px;"><button class="close" data-dismiss="alert" type="button">×</button>
    Раздел на реконструкции. Ориентировочно на 20-30 минут. Прошу прощения за неудобства</div>'; exit; }

    tcore, 30 Октября 2014

    Комментарии (15)
  3. C++ / Говнокод #16991

    +137

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    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
    37. 37
    38. 38
    39. 39
    40. 40
    _DECLSPEC void StringToHex(
       const _tstring &ts, 
       BYTE *pBuffer, 
       size_t nBytes)
    {
       USES_CONVERSION;
    
       const std::string s = T2A(const_cast<PTSTR>(ts.c_str()));
    
       for (size_t i = 0; i < nBytes; i++)
       {
          const size_t stringOffset = i * 2;
    
          BYTE val = 0;
    
          const BYTE b = s[stringOffset];
    
          if (isdigit(b)) 
          {
             val = (BYTE)((b - '0') * 16); 
          }
          else 
          {
             val = (BYTE)(((toupper(b) - 'A') + 10) * 16); 
          }
    
          const BYTE b1 = s[stringOffset + 1];
    
          if (isdigit(b1)) 
          {
             val += b1 - '0' ; 
          }
          else 
          {
             val += (BYTE)((toupper(b1) - 'A') + 10); 
          }
    
          pBuffer[i] = val;
       }
    }

    ночнём-с, ребзя!

    blackhearted, 30 Октября 2014

    Комментарии (0)
  4. Куча / Говнокод #16990

    +126

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    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
    .cat_mid a{
    color: #ffa10e !important;
    }
    .cat_mid {
    padding: 0 10px;
    display: inline-block;
    font-family: georgia, "times new roman", times, serif;
    font-weight: normal;
    font-size: 14px;
    height: 64px !important;
    overflow: hidden;
    margin-bottom: -3px !important;
    padding: 10px 10px 0;
    }
    .cat_hid {
    color: #bc843f;
    padding: 0 10px;
    text-align: left; 
    z-index: 100;
    position: relative;
    display: none;
    }
    .cat_hid.not{
    display: block !important;
    padding: 8px 10px 19px;
    }
    .cat_hid.not.price{
    height: 25px;
    padding: 12px 10px 17px;
    }

    css

    UncaughtException, 30 Октября 2014

    Комментарии (1)
  5. PHP / Говнокод #16988

    +145

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    ПРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРР
    РРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРР
    РРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРР
    РРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРР
    РРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРР
    РРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРР
    РРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРР
    РРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРР
    РРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРР
    РРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРРР

    ПОСРАЛ В ГОВНОКОДАЧОК НЕ СМЫЛ БАЧОК

    Stulchak, 30 Октября 2014

    Комментарии (0)
  6. C++ / Говнокод #16986

    +145

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    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
    int boolToInt(bool b)
    {
    	bool * boolPtr = &b;
    	char * boolToCharPtr = reinterpret_cast<char *>(boolPtr);
    	char * resultCharPtr;
    	resultCharPtr = (char*) malloc(4);
    
    	for (int i = 0; i < sizeof(int); i++)
    	{
    		if (i == 0)
    		{
    			resultCharPtr[i] = boolToCharPtr[0];
    		}
    		if (i == 1)
    		{
    			resultCharPtr[i] = 0x00;
    		}
    		if (i == 2)
    		{
    			resultCharPtr[i] = 0x00;
    		}
    		if (i == 3)
    		{
    			resultCharPtr[i] = 0x00;
    		}
    	}
    
    	int * intPtr = reinterpret_cast<int *> (resultCharPtr);
    	return *intPtr;
    }

    Удобная функция для конвертации bool в int

    lazorg, 29 Октября 2014

    Комментарии (3)
  7. Куча / Говнокод #16977

    +142

    1. 1
    <img title="(495) 980-68-49" alt="(495) 980-68-49" src="/images/phones/9c1fc37d7d851137eca84579f7346b66">

    Защита от граба данных
    Уровень: Бог

    http://www.plan1.ru/podolsk/magazinyi/salonyi-svyazi/

    dekameron, 29 Октября 2014

    Комментарии (2)
  8. Куча / Говнокод #16966

    +134

    1. 1
    2. 2
    3. 3
    4. 4
    {GENDER, select,
        male {He}
      female {She}
       other {They}

    https://github.com/SlexAxton/messageformat.js

    someone, 29 Октября 2014

    Комментарии (15)
  9. Perl / Говнокод #16965

    −161

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    sub check_license {
        my ($license) = @_;
    
        my $is_valid = 0;
        if (-f $license) {
            open(my $fh, '<', $license);
            my $content = do { local $/ = undef; <$fh> };
            close($fh);
            $content =~ s/\r\n/\n/g;
    
            $is_valid = $content =~ /^-{5}BEGIN LICENSE-{5}$/m;
            $is_valid = $content =~ /^-{5}END LICENSE-{5}$/m;
        }
    
        return $is_valid;
    }

    Ну ок.

    Elvenfighter, 29 Октября 2014

    Комментарии (17)
  10. JavaScript / Говнокод #16964

    +155

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    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
    $(function() {
    			$('#diametr').on('change', function() {
    				window.location = '/catalog/<?=$arResult['SECTION']['CODE']?>/'+this.value+'/';
    			});
    			
    			$('#type_s').on('change', function() {
    				$('#size_s').find('option:enabled').prop("disabled", true);
    				$('#size_s').find('option[data-prop-material='+$(this).find('option:selected').data('propMaterial')+']').prop("disabled", false).first().prop("selected", true);
    				$('#size_s').trigger('change')
    			});
    			
    			$('#type_p').on('change', function() {
    				$('#size_p').find('option:enabled').prop("disabled", true);
    				$('#size_p').find('option[data-prop-type='+$(this).find('option:selected').data('propType')+']').prop("disabled", false).first().prop("selected", true);
    				$('#size_p').trigger('change')
    			});
    			
    			
    			$(document)
    				.on('change', '#size_s, #size_p', function() {
    					
    					$('#selected_prop').val('csone_19_'+$(this).find('option:selected').data('propId'));
    				})
    				.on('click', '.but_sita', function() {
    					console.log($(this).parent().find('select').first());
    					$(this).parent().find('select').first().trigger('change');
    				});
    			$('.but_sita').last().trigger('click');
    			
    			$('#additional_spoiler').on('click', function(e) {
    				e.preventDefault();
    				$('#additional').fadeIn();
    			});
    		});

    UncaughtException, 29 Октября 2014

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