1. Лучший говнокод

    В номинации:
    За время:
  2. JavaScript / Говнокод #19739

    −2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    if(this.options.raining){
          this.dropletsCounter+=this.options.dropletsRate*timeScale*this.areaMultiplier;
          times(this.dropletsCounter,(i)=>{
            this.dropletsCounter--; // зачем это тут?
            this.drawDroplet(
              random(this.width/this.scale),
              random(this.height/this.scale),
              random(...this.options.dropletsSize,(n)=>{
                return n*n;
              })
            )
    });

    завис на этой строке... https://github.com/codrops/RainEffect/blob/master/src/raindrops.js

    makc3d, 01 Апреля 2016

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

    +2

    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
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    public interface ICachedObject<TCachedValue>
        {
            TCachedValue Value { get; set; } 
        } 
    
    public interface ICacheProvider<TCachedObject, TCachedValue>
            where TCachedObject : ICachedObject<TCachedValue>
        {
            TCachedObject Get(string key);
    
            void Set(string key, TCachedObject value);
    
            void Remove(string key);
    
            IEnumerable<TCachedObject> GetAll();
        }
    
    public class CachedEntityObject : ICachedObject<IEntity>
        {
            public EntityState State { get; set; }
    
            public IEntity Value { get; set; }
        }
    
        public abstract class CacheProvider<TCache, TCachedObject, TCachedValue> :
            ICacheProvider<TCachedObject, TCachedValue> 
            where TCache : IDictionary<string, TCachedObject>
            where TCachedObject : ICachedObject<TCachedValue>
        {
            protected TCache Cache;
    
            protected abstract void InitializationCache();
    
            public abstract TCachedObject Get(string key);
    
            public abstract void Set(string key, TCachedObject value);
    
            public abstract void Remove(string key);
    
            public abstract IEnumerable<TCachedObject> GetAll();
        }
    
     public class CacheEntity : CacheProvider<Dictionary<string, CachedEntityObject>, CachedEntityObject, IEntity>
        {
            public CacheEntity()
            {
                InitCache();
            }
    
            protected sealed override void InitCache()
            {
                Cache = new Dictionary<string, CachedEntityObject>();
            }
    
            public override CachedEntityObject Get(string key)
            {
                if (Cache[key] == null)
                    throw new NullReferenceException($"{nameof(key)} not found from cache list");
    
                return Cache[key];
            }
    
            public override void Set(string key, CachedEntityObject value)
            {
                Remove(key);
    
                Cache[key] = value;
            }
    
            public override void Remove(string key)
            {
                if (Cache.ContainsKey(key))
                    Cache.Remove(key);
            }
    
            public override IEnumerable<CachedEntityObject> GetAll()
            {
                return Cache.Values;
            }
        }

    Кэш сущностей

    Serega9I, 31 Марта 2016

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

    0

    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
    $f = fopen("./.htaccess", "r");
    			while (!feof($f)) {
    			    $tmp = fgets($f);
    			    $tmp = str_replace(REDIRECT_USER."/", $_POST["redir_user"]."/", $tmp);
    			    $tmp = str_replace(REDIRECT_SHOP."/", $_POST["redir_shop"]."/", $tmp);
    			    $tmp = str_replace(REDIRECT_ADMIN."/", $_POST["redir_admin"]."/", $tmp);
    			    $tmp = str_replace(REDIRECT_NEWS."/", $_POST["redir_news"]."/", $tmp);
    			    $tmp = str_replace(REDIRECT_CART."/", $_POST["redir_cart"]."/", $tmp);
    			    $tmp = str_replace(REDIRECT_PAYMENT."/", $_POST["redir_payment"]."/", $tmp);
    			    $tmp = str_replace(REDIRECT_INFO."/", $_POST["redir_info"]."/", $tmp);
    			    $line[] = $tmp;
    			}
    			fclose($f);

    Настройка редиректов из админки

    drop_database, 29 Марта 2016

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

    +5

    1. 1
    https://meduza.io/shapito/2016/03/24/iskusstvennyy-intellekt-ot-microsoft-za-sutki-polyubil-gitlera-i-voznenavidel-feministok

    RIP in peace, nazi AI ;_;

    CHayT, 25 Марта 2016

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

    0

    1. 1
    if(0+$count_options!=0)

    sevenflash, 07 Марта 2016

    Комментарии (5)
  7. C# / Говнокод #19584

    0

    1. 1
    int k = 1000 - 1000 / 7 *7;

    Процент? Что такое процент?

    nicko, 07 Марта 2016

    Комментарии (5)
  8. JavaScript / Говнокод #19577

    −1

    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
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    module Bert {
      export class Decoder {
        private b: ArrayBuffer;
        private d: DataView;
        private i: number = 0;
        result: any;
        constructor(packet: ArrayBuffer) {
          this.b = packet;
          this.d = new DataView(packet);
          if (131 == this.d.getUint8(this.i++)) {
            this.result = this.decode();
          } else {
            throw 'Not BERT';
          }
        }
        decode() {
          var tag = this.d.getUint8(this.i++);
          var r: any;
          switch (tag) {
            case 100: r = this.decodeAtom(); break; // latin1 atom
            case 107: r = this.decodeString(); break; // utf8 string
            case 109: r = this.decodeBinary(); break; // utf8 binary string
            case 115: r = this.decodeSmallAtom(); break; // latin1 atom
            case 118: r = this.decodeAtom(); break; // utf8 atom
            case 119: r = this.decodeSmallAtom(); break; // utf8 atom
          }
          return r;
        }
        decodeAtom() {
          var length = this.d.getUint16(this.i);
          this.i += 2;
          var dec = new Utf8.Decoder(this.b.slice(this.i, this.i + length));
          this.i += length;
          return dec.result;
        }
        decodeSmallAtom() {
          var length = this.d.getUint8(this.i++);
          var dec = new Utf8.Decoder(this.b.slice(this.i, this.i + length));
          this.i += length;
          return dec.result;
        }
        decodeString() {
          var length = this.d.getUint16(this.i);
          this.i += 2;
          var dec = new Utf8.Decoder(this.b.slice(this.i, this.i + length));
          this.i += length;
          return dec.result;
        }
        decodeBinary() {
          var length = this.d.getUint32(this.i);
          this.i += 4;
          var dec = new Utf8.Decoder(this.b.slice(this.i, this.i + length));
          this.i += length;
          return dec.result;
        }
        ...
      }
    }

    Перед тем, как избавлюсь от повторяющегося кода в нижней части
    (typescript)

    kgm-rj, 04 Марта 2016

    Комментарии (5)
  9. Куча / Говнокод #19550

    +4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    // Итальянский код
    
    if (...) {
       ...
    } else {
       ...
    } elsinio {
       ...
    }

    3_dar, 29 Февраля 2016

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

    −97

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    ПроцентОтОплаты = 0;
    		
    Если ЗначениеЗаполнено(Процент) Тогда			
    	ПроцентОтОплаты = Окр((ВыборкаПоГруппам.КОплате * 100 / (100 - Процент )) - ВыборкаПоГруппам.КОплате, 2);   			
    КонецЕсли; 
    ...
    мСтруктураДанных.Вставить("ИтогоКОплатеСУчетомПредоплаты",    ВыборкаПоГруппам.КОплате + ПроцентОтОплаты);

    Всё та же конфигурация...
    Если на форме выставили 10% предоплаты на 100р услуг, то некий сбор в пользу бедных будет 1,11р., а к оплате жильцу 111,11р.
    Если на форме выставили 15% предоплаты на 100р услуг, то некий сбор в пользу бедных будет 2,64р., а к оплате жильцу 117,64р.
    Если на форме выставили 99% предоплаты на 100р услуг, то некий сбор в пользу бедных будет 9900р., а к оплате жильцу 10000р.
    Если на форме выставили 100% предоплаты на 100р услуг, то будет крах босякам...

    Великий и могучий русский язык, но язык 1С его переплюнул тысячекратно... (

    ivan_0110, 05 Февраля 2016

    Комментарии (5)
  11. JavaScript / Говнокод #19399

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    var ta = $( '#Modal form textarea');
         for(var i = 0, len = ta.length; i < len; i++) {
             $(ta[i]).html('');$(ta[i]).val('');$(ta[i]).text('');
         }

    deep, 04 Февраля 2016

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