1. C# / Говнокод #25380

    +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
    public static void Init()
            {            
                LetterOrder = new Dictionary<char, int>
                              {
                                  {'A', 0},
                                  {'B', 1},
                                  {'C', 2},
                                  {'D', 3},
                                  {'E', 4},
                                  {'F', 5},
                                  {'G', 6},
                                  {'H', 7},
                                  {'I', 8},
                                  {'J', 9},
                                  {'K', 10},
                                  {'L', 11},
                                  {'M', 12},
                                  {'N', 13},
                                  {'O', 14},
                                  {'P', 15},
                                  {'Q', 16},
                                  {'R', 17},
                                  {'S', 18},
                                  {'T', 19},
                                  {'U', 20},
                                  {'V', 21},
                                  {'W', 22},
                                  {'X', 23},
                                  {'Y', 24},
                                  {'Z', 25},
                              };
            }

    C#-макака не умеющая, ни в char - 'A' ни в статические конструторы (и еще много чего: см. https://www.codingame.com/training/easy/encryptiondecryption-of-enigma-machine/solution?id=10246815)

    Lorip1971, 15 Февраля 2019

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

    0

    1. 1
    https://www.bellingcat.com/resources/how-tos/2019/02/14/creating-your-own-citizen-database/

    Новые веяния - код в виде скриншотов, сырцы скачать нельзя.

    syoma, 15 Февраля 2019

    Комментарии (212)
  3. JavaScript / Говнокод #25378

    +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
    checkDateNP(value) {
            const date = new Date(value)
            const dateValue = date.setDate(date.getDate() + 1)
    
            return formatDate(dateValue, 'DD-MM-YYYY') === formatDate(this.item.date, 'DD-MM-YYYY') &&
            formatDate(dateValue, 'DD-MM-YYYY') === formatDate(this.item.dateEnd, 'DD-MM-YYYY')
          },
    
          checkDateOther(value) { // Проверка корреткности ввода данных по заявкам типа "КА" и "МС".
            return formatDate(this.item.startTime, 'DD-MM-YYYY') >= formatDate(this.item.date, 'DD-MM-YYYY')
          }
        }

    VueJs. Проверка корреткности ввода данных по заявкам

    DKVitol, 14 Февраля 2019

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

    +3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    changeTypeNames: function(value) {
            return value.replace(/\[|\]|\,/gi, function(excerpt) {
              if (excerpt === ',') {
                return ', '
              } else {
                return ''
              }
            })
          }

    VueJs. Преобразование JSON массива в стандартную строку.

    DKVitol, 14 Февраля 2019

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    public function putSitemapContent(SitemapFile $sitemapFile)
    	{
    //		always write in new empty file - tak nado, a to pechalka ((
    		if ($this->isExists())
    			$this->delete();

    1C-Битрикс - серьезный фреймворк для решения бизнес-задач.
    (код исходников)

    quentiam, 14 Февраля 2019

    Комментарии (1)
  6. Си / Говнокод #25375

    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
    // https://git.zx2c4.com/BruteZip/tree/read.c?id=e4e9c17b99e0d108136b8a07632b1ebaa7d09d28#n26
    
    int main(int argc, char *argv[])
    {
    	union {
    		long int l;
    		char c[sizeof(long int)];
    	} u;
    	u.l = 1;
    	if (u.c[sizeof(long int) - 1] == 1) {
    		printf("This program only runs on little endian archs, because I'm lazy. Sorry.\n");
    		return -2;
    	}

    Хуйня какая-то. Ведь sizeof(long int) может быть равен sizeof(char).

    Но над такой питушней обычно никто не задумывается

    j123123, 13 Февраля 2019

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    Офигеть, sql-дамп говнокода весит всего 240Мб.
    
    Может переписать на "C++" и держать все индексы в памяти?
    А на фронте будет только обращение к JSON API. И можно хоть мобильное приложение делать на "Electron.js".
    Клиент будет подписан на интересующие его события, например на сток и на ответы на его коменты.
    Никто не хочет заняться по фану?

    guestinxo, 12 Февраля 2019

    Комментарии (49)
  8. bash / Говнокод #25373

    0

    1. 1
    jopa | parasha

    Допустим jopa бесконечно срёт в STDOUT.
    parasha это всё читает из STDIN.
    Что будет делать ОС, если параша не будет успевать читать высеры?
    Держать в памяти? Сохранять на диск?

    Perevedi_na_PHP, 12 Февраля 2019

    Комментарии (114)
  9. Си / Говнокод #25372

    −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
    // http://p99.gforge.inria.fr/p99-html/group__flexible.html
    
    //C99 allows a flexible array member to be defined as the last member of a struct,
    // namely an array of undetermined length.
    //P99_DECLARE_STRUCT(package_head);
    
    struct package_head {
      char name[20];
      size_t len;
      uint64_t data[];
    };
    
    // Such a struct can then be allocated on the heap with a suitable size such 
    // that the field data has as many elements as fit in the allocated space from
    // the start of data onward. Usually one would allocate such struct with
    
    package_head *a = malloc(sizeof(package_head) + 10 * sizeof(uint64_t));
    package_head *b = malloc(sizeof(*b) + 12 * sizeof(b->data[0]));
    
    // This has several disadvantages. Firstly, the syntax is clumsy. We have to
    // use a relatively complicated expression that uses two elements of the specification of a or b.
    
    // Secondly, it wastes space. Due to packing of the struct the offset of data "inside"
    //  the struct may be less than sizeof(package_head). In most cases the real size
    // of the object that we want to construct is
    
    offsetof(package_head, data) + N * sizeof(uint64_t)
    
    // so we are wasting
    
    sizeof(package_head) - offsetof(package_head, data)
    
    // bytes.
    
    // The above formula for the exact size is only valid for larger values of N. We must
    // also ensure that we allocate at least sizeof(package_head) bytes. So the complete
    // formula looks something like
    
    #define P99_FSIZEOF(T, F, N) P99_MAXOF(sizeof(T), offsetof(T, F) + P99_SIZEOF(T, F[0]) * N)
    
    // which is probably not something that you want to write on a daily basis.
    
    // We provide several interfaces to allocate struct with flexible members

    Херню написали какую-то. Забыли самое главное : нельзя так в лоб аллоцировать память под структуры. Потому что выравнивание может не то быть.
    Надо использовать http://man7.org/linux/man-pages/man3/aligned_alloc.3.html

    j123123, 12 Февраля 2019

    Комментарии (25)
  10. PHP / Говнокод #25371

    0

    1. 1
    Чего нету в "PHP"?

    Perevedi_na_PHP, 10 Февраля 2019

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